Skip to content

Instantly share code, notes, and snippets.

@shaenr
Created December 8, 2019 09:10
Show Gist options
  • Save shaenr/03c03c589dc576a857b8278e060cf94c to your computer and use it in GitHub Desktop.
Save shaenr/03c03c589dc576a857b8278e060cf94c to your computer and use it in GitHub Desktop.
Write out dict paths to deeper data from elaborate json using dot notation...
def get_value(d, key_str):
for key in key_str.split('.'):
d = d[key]
return d
content = {'html_data': {'footer':{'elements': []}}}
result = get_value(content, 'html_data.footer.elements')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment