[Solved] Return nested JSON item that has multiple instances


As the commenter points out you’re treating the list like a dictionary, instead this will select the name fields from the dictionaries in the list:

list((item['fields']['components'][i]['name'] for i, v in enumerate(item['fields']['components'])))

Or simply:

[d['name'] for d in item['fields']['components']]

You’d then need to apply the above to all the items in the iterable.

EDIT: Full solution to just print the name fields, assuming that “issues” is a key in some larger dictionary structure:

for list_item in data["issues"]: # issues is a list, so iterate through list items
    for dct in list_item["fields"]["components"]: # each list_item is a dictionary
        print(dct["name"]) # name is a field in each dictionary

9

solved Return nested JSON item that has multiple instances