How do I convert an
When you convert an
OrderedDict to a normal
dict, you can't guarantee the ordering will be the preserved, because dicts are unordered. Which is why
OrderedDict exists in the first place.
It seems like you're trying to have your cake and eat it too, here. If you want the order of the JSON string preserved, use the answer from the question I linked to in the comments to load your json string directly into an
OrderedDict. But you have to deal with whatever performance penalty that carries (I don't know offhand what that penalty is. It may even be neglible for you use-case.). If you want the best possible performance, just use
dict. But it's going to be unordered.