This is the clearest coding tutorial I've ever seen in my life. Liz you are awesome. Very high quality step by step break down of the problem and solution.
Here is the code that will work on all data structures def run_on_dict(data): for key, value in data.items(): if isinstance(value, dict): run_on_dict(value) elif isinstance(value, list): for element in value: if isinstance(element, (dict, list)): run_on_dict(element) else: print(f"{key}: {element}") else: print(f"{key}: {value}")
Nice tutorial, thanks! Have you got any tips if I want to only output specific keys in the json object? (Parameterised as a list) Eg json object: obj = {'key1' : {'key2': {'key3': 'value1', 'key4': 'value2' } } } When caling the flatten function: flatten_json( obj, ["key1.key2", "key3.key4"]) Desired output: { "key1.key2": "value1", "key3.key5": "value3" }
This is the clearest coding tutorial I've ever seen in my life. Liz you are awesome. Very high quality step by step break down of the problem and solution.
Liz, I love you for this. You saved my life. I will watch all of your other videos. Thank you so much! I really appreciate it!
Thank you! I REALLY needed this.
Thank you for the clear explanation!
One helluva good explanation! Please keep making videos
Hey, what if we want to get back from flatten to json object?
I think this solution may break down in the list section if the elements within the list are dicts? Need to test it though to be sure.
Very clear. Very concise. First time I've come across your videos. How you have more of these. Thank you.
How do I take one key value pair based on some condition , like from ur example I want city in Canada that starts with M
great explanation, thank you. what if you want the output in a tabular form
Too good so well explained
Here is the code that will work on all data structures
def run_on_dict(data):
for key, value in data.items():
if isinstance(value, dict):
run_on_dict(value)
elif isinstance(value, list):
for element in value:
if isinstance(element, (dict, list)):
run_on_dict(element)
else:
print(f"{key}: {element}")
else:
print(f"{key}: {value}")
where is the code? Please provide the link so that it can be test.
Nice tutorial, thanks!
Have you got any tips if I want to only output specific keys in the json object? (Parameterised as a list)
Eg json object:
obj = {'key1' :
{'key2':
{'key3': 'value1',
'key4': 'value2'
}
}
}
When caling the flatten function:
flatten_json( obj, ["key1.key2", "key3.key4"])
Desired output:
{
"key1.key2": "value1",
"key3.key5": "value3"
}
That jacket of yours, that logo is cool! :)
Thank you (!!)
Awesome 👍
thank you
Nice.