Trying to loop from API response need help with nested JSON
I only have a few months of learning python so I don't have much experience. I'm trying to get results of a API response so I can make another API call. I need to get the portID and system name so I can make the 2nd API call I want. I only need the LLDP information since that has the information I need. Below I have the first two API calls that I have come up with. I'm having issues with the lldp_results. Since it's nested I don't know how to loop through it. Below is the script that I have. import pprint import meraki API_KEY = KEY dashboard = meraki.DashboardAPI(API_KEY) organization_id = 'ORG-ID' response = dashboard.organizations.getOrganizationInventoryDevices( organization_id, total_pages='all', productTypes='switch' ) for switch in response: lldp_results = dashboard.devices.getDeviceLldpCdp( switch['serial'] ) pprint.pprint(lldp_results) This is the lldp_results information [{'ports': {'1': {'lldp': {'portId': 'c8:d9:d2:cc:bb:aa', 'sourcePort': '1'}}, '12': {'lldp': {'portId': '50:a4:d0:cc:bb:aa', 'sourcePort': '12'}}, '13': {'lldp': {'portId': '48:21:0b:cc:bb:aa', 'sourcePort': '13'}}, '14': {'lldp': {'portId': '50:a4:d0:cc:bb:aa', 'sourcePort': '14'}}, '15': {'lldp': {'portId': '48:21:0b:cc:bb:aa', 'sourcePort': '15'}}, '3': {'lldp': {'portId': '00:07:32:cc:bb:aa', 'sourcePort': '3'}}, '37': {'cdp': {'address': '10.60.138.82', 'deviceId': 'AABBCCDDEEFF', 'portId': 'Port 1', 'sourcePort': '37'}, 'lldp': {'managementAddress': '10.60.138.82', 'portId': 'AABBCCDDEEFF:P1', 'sourcePort': '37', 'systemName': 'AABBCCDDEEFF'}}, '4': {'lldp': {'portId': '50:a4:d0:92:bb:aa', 'sourcePort': '4'}}, '43': {'cdp': {'address': '10.60.138.81',