I have the following json structure in a file:
[
{ "Date": "timevalue", "Org": "b4256282", "Referer": "somevalue" },
{ "Date": "timevalue", "Org": "b4257482", "Referer": "somevalue" },
{ "Date": "timevalue", "Org": "b4253345", "Referer": "somevalue" },
....
]
I want to extract all the Org's.
My code is:
import json
jdata = json.loads(str_of_above_json)
for orgs in jdata['Org']:
print(orgs)
However this code does not work ... I get the following error messag
TypeError: list indices must be integers, not str
Can anyone let me know what I am doing wrong?
for orgs in jdata: print(orgs['Org'])orgswill be the dictionary, which then you can access the 'Org' key.