Skip to content

Instantly share code, notes, and snippets.

@macedd
Last active March 24, 2019 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macedd/8304baf87897fb32e65dd276ca50e811 to your computer and use it in GitHub Desktop.
Save macedd/8304baf87897fb32e65dd276ca50e811 to your computer and use it in GitHub Desktop.
Normalize nested Json into Flat dict structure
def json_flat(item, nest=''):
new = {}
for k,v in item.iteritems():
key = '%s_%s' % (nest, k) if nest else k
if isinstance(v, dict):
new.update(json_flat(v, k))
else:
new[key] = v
return new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment