Last active
September 26, 2017 15:15
-
-
Save fhightower/f56a244f8f8a9ca5c0e0a5886d75bf31 to your computer and use it in GitHub Desktop.
Print the paths of json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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