I\'m using Python to parse through some JSON data for specific values. Specifically I want to pull the following:
It's exactly as the error says. fields['events']
is a list, so you can't index it with ['public']
. You need to iterate through the values, each of which is a dictionary.
for event in fields['events']:
print event['public']
print(fields['events'][0]['public'])
fields['events']
is a list so you need to use ['events'][0]
to access the dict inside the list.
Insted of fields['events']['public']
it should be fields['events'][0]['public']