How to get JSON to load into an OrderedDict in Python?

Posted by Ramesh Singh | Updated on

If you want to get JSON to load into an OrderedDict in Python? You can get by specifying the object_pairs_hook argument to JSONDecoder. In fact, this is the exact example given in the documentation.

You can pass this parameter to json.loads (if you don’t need a Decoder instance for other purposes) like so:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers