Skip to content

Instantly share code, notes, and snippets.

@cadu-leite
Created July 31, 2020 01:15
Show Gist options
  • Save cadu-leite/faca1fab617ad2a93afaa46353355a4f to your computer and use it in GitHub Desktop.
Save cadu-leite/faca1fab617ad2a93afaa46353355a4f to your computer and use it in GitHub Desktop.
# "convert"or transform a Json to objet attributes
# converte ou transforma um Json em objeto com atributos
def _json_object_hook(d:Dict):
return namedtuple('X', d.keys(), rename=True)(*d.values())
def json2obj(data_json: str):
return json.loads(data_json, object_hook=_json_object_hook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment