How to convert JSON data into a Python object?

Posted by Jessica Taylor | Updated on

Want to convert JSON data into a Python object? You can do it in one line, using named-tuple and object_hook:

or, to reuse this easily:

If you want it to handle keys that aren’t good attribute names, check out namedtuple’s rename parameter.


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