Question

Difficulty: MediumInterpreting JSON Encoded Data

A network automation engineer issues a REST API call to a Cisco Catalyst 9800 Wireless LAN Controller to inspect access point operational telemetry. The controller returns the following JSON encoded response:

{
"response": {
"access_points": [
{
"name": "AP-Lobby-01",
"ip_address": "10.20.40.15",
"radios": [
{ "radio_id": 0, "band": "2.4GHz", "channel": 6, "admin_state": true },
{ "radio_id": 1, "band": "5GHz", "channel": 36, "admin_state": true }
]
},
{
"name": "AP-Conf-02",
"ip_address": "10.20.40.16",
"radios": [
{ "radio_id": 0, "band": "2.4GHz", "channel": 11, "admin_state": false },
{ "radio_id": 1, "band": "5GHz", "channel": 149, "admin_state": true }
]
}
]
}
}

Match each JSON data path expression on the left to its corresponding value on the right based on the returned JSON payload.

  • response.access_points[0].radios[1].channel36
  • response.access_points[1].ip_address"10.20.40.16"
  • response.access_points[1].radios[0].admin_statefalse
  • response.access_points[0].name"AP-Lobby-01"

Answer

Path response.access_points[0].radios[1].channel maps to 36; response.access_points[1].ip_address maps to "10.20.40.16"; response.access_points[1].radios[0].admin_state maps to false; response.access_points[0].name maps to "AP-Lobby-01".
JSON arrays utilize 0-based indexing. Navigating response.access_points[0] accesses the first access point ('AP-Lobby-01'), and navigating inside its radios array with [1] accesses the second radio (5GHz), yielding channel 36. Similarly, access_points[1] selects the second access point ('AP-Conf-02'), yielding an ip_address of "10.20.40.16" and radios[0].admin_state of false. Finally, access_points[0].name yields "AP-Lobby-01".

Step-by-Step Solution

1
Understand zero-based list indexing in JSON structures
Index 0 refers to the first element in an array, while index 1 refers to the second element.
JSON arrays are 0-indexed sequences of items.
2
Trace response.access_points[0].radios[1].channel
Under 'response', enter 'access_points[0]' (first AP: AP-Lobby-01), then enter 'radios[1]' (second radio: 5GHz radio object), then read key 'channel' which equals 36.
Navigating nested object keys and array indices retrieves the specific scalar value.
3
Trace response.access_points[1].ip_address
Under 'response', enter 'access_points[1]' (second AP: AP-Conf-02), and read key 'ip_address' which equals "10.20.40.16".
Index 1 targets the second item in the access_points array.
4
Trace response.access_points[1].radios[0].admin_state
Under 'response', enter 'access_points[1]' (second AP: AP-Conf-02), enter 'radios[0]' (first radio: 2.4GHz radio object), and read key 'admin_state' which equals false.
Index 0 targets the first element of the radios array inside the second access point.
5
Trace response.access_points[0].name
Under 'response', enter 'access_points[0]' (first AP: AP-Lobby-01), and read key 'name' which equals "AP-Lobby-01".
Index 0 targets the top-level array's first dictionary element.

Key Concept

Interpreting JSON Encoded Data
Rate this question