A Python script uses the `requests` library to fetch device details from Cisco DNA Center. The API returns a JSON response with nested objects. To extract the management IP address from the response stored in variable `data`, which code snippet is correct? The JSON structure is: { "response": [ { "managementIpAddress": "192.168.1.1", "hostname": "router1" } ] }
Accessing `data['response']` yields the JSON array, and `[0]` selects its first element, the device object. Indexing that dictionary with `['managementIpAddress']` returns the nested string "192.168.1.1". This directly satisfies the stem's requirement to extract the management IP from the nested structure.
Why this answer
The response contains a list under key 'response'; correct access is via data['response'][0]['managementIpAddress'].