string indices must be integers while parsing JSON - python string indices must be integers while parsing JSON - python json json

string indices must be integers while parsing JSON - python


.values() is used to loop through the values of a dictionary however, team_data['NFLTeams'] is a list containing dictionaries. Thus, you need to remove .values() to access each dictionary whilst iterating:

for item in team_data['NFLTeams']:    print (item["code"])    print (item['fullName'])    print (item['shortName'])

If you really want to use .values():

for item in team_data.values()[0]:    print (item["code"])    print (item['fullName'])    print (item['shortName'])

Please keep in mind that .values() returns a view object in Python 3.x, so you need to force evaluating it using list() in order to access the elements by index:

for item in list(team_data.values())[0]: