I’m aware the code won’t work because i can’t work out how to access each array.
Person-Ryan, Personal-Luke.
There will be multiple and each will be unique and won’t know what they be called beforehand.
I would like to print the name on each one in a loop.
Json:
"entities": {
"Person-Ryan": {
"name":"Ryan"
},
"Person-Luke": {
"name": "Luke"
}
}
Code:
res_json = response.json()
for inner_dict in res_json:
Test = inner_dict['name']
print (Test)
>Solution :
I think what you need is just calling items function on the dictionary that you get from response.json():
for key, value in res_json["entities"].items():
print(value["name"])
Output
Ryan
Luke