Skip to content

Instantly share code, notes, and snippets.

@nderkach
Created November 26, 2017 11:55
Show Gist options
  • Save nderkach/58c3ad7a27616265d081a1976d78e99d to your computer and use it in GitHub Desktop.
Save nderkach/58c3ad7a27616265d081a1976d78e99d to your computer and use it in GitHub Desktop.
How to convert JSON data into a Python object
# stolen from https://stackoverflow.com/questions/6578986/how-to-convert-json-data-into-a-python-object/15882054#15882054
def _json_object_hook(d):
return namedtuple('X', d.keys())(*d.values())
def json2obj(data):
return json.loads(data, object_hook=_json_object_hook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment