If you have a multilevel, nested json from url:
import json
import urllib.request
data = urllib.request.urlopen("https://url").read()
output = json.loads(data)
for each in output['toplevel']:
Key = each['Key']
Value = each['Value']
string = {Key:Value}
print(dict(new_context = string))
This return:
{'new_context': {'the_Key1': 'the_Value1'}}
{'new_context': {'the_Key2': 'the_Value2'}}
{'new_context': {'the_Key3': 'the_Value3'}}
What i want:
{'new_context': {'the_Key1': 'the_Value1', 'the_Key2': 'the_Value2', 'the_Key3': 'the_Value3'}}