Skip to content

Instantly share code, notes, and snippets.

@fhightower
Last active September 26, 2017 15:15
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 fhightower/f56a244f8f8a9ca5c0e0a5886d75bf31 to your computer and use it in GitHub Desktop.
Save fhightower/f56a244f8f8a9ca5c0e0a5886d75bf31 to your computer and use it in GitHub Desktop.
Print the paths of json
def print_keys(dictionary, parent_key):
if len(dictionary.keys()) > 0:
for key in dictionary.keys():
if isinstance(dictionary[key], dict):
print_keys(dictionary[key], parent_key + ":" + key)
elif isinstance(dictionary[key], list):
if isinstance(dictionary[key][0], dict):
print_keys(dictionary[key][0], parent_key + ":" + key + "[x]")
else:
print(parent_key + ":" + key)
else:
print(parent_key + ":" + key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment