Question

Difficulty: HardInterpreting JSON Encoded Data

A network automation engineer sends an HTTP GET request to a Cisco IOS XE RESTCONF endpoint to check IP SLA operation status. The API returns the following JSON payload:

{
"Cisco-IOS-XE-sla:sla": {
"ip-sla": [
{
"oper-id": 101,
"type": "icmp-echo",
"destination": "192.168.50.1",
"stats": {
"rtt-ms": 14,
"state": "active",
"history": [
{"sample-id": 1, "rtt": 12, "success": true},
{"sample-id": 2, "rtt": 16, "success": true}
]
}
},
{
"oper-id": 102,
"type": "udp-jitter",
"destination": "10.10.20.5",
"stats": {
"rtt-ms": 4,
"state": "inactive",
"history": [
{"sample-id": 1, "rtt": 4, "success": false}
]
}
}
]
}
}

Based on the JSON payload provided above, match each data extraction path on the left to its correct extracted value and data type on the right.

  • `Cisco-IOS-XE-sla:sla` → `ip-sla[0]` → `stats` → `state`"active" (String)
  • `Cisco-IOS-XE-sla:sla` → `ip-sla[1]` → `destination`"10.10.20.5" (String)
  • `Cisco-IOS-XE-sla:sla` → `ip-sla[0]` → `stats` → `history[1]` → `rtt`16 (Number)
  • `Cisco-IOS-XE-sla:sla` → `ip-sla[1]` → `stats` → `history[0]` → `success`false (Boolean)

Answer

The correct matches map each zero-indexed JSON array path to its corresponding value and type: `ip-sla[0]->stats->state` maps to `"active" (String)`, `ip-sla[1]->destination` maps to `"10.10.20.5" (String)`, `ip-sla[0]->stats->history[1]->rtt` maps to `16 (Number)`, and `ip-sla[1]->stats->history[0]->success` maps to `false (Boolean)`.
All four extraction paths correctly evaluate zero-based array indices (`[0]` for first element, `[1]` for second element) and trace object key structures to their exact primitive values and data types.

Step-by-Step Solution

1
Locate top-level keys and array indices
The top-level key `Cisco-IOS-XE-sla:sla` contains an array named `ip-sla`. Index `[0]` refers to the first object (`oper-id` 101), and index `[1]` refers to the second object (`oper-id` 102).
JSON arrays use zero-based indexing, where the first element is at index 0.
2
Extract direct keys from array elements
For `ip-sla[0] -> stats -> state`, the value is `"active"`. For `ip-sla[1] -> destination`, the value is `"10.10.20.5"`.
Navigating directly through key-value maps yields the string values bound to those keys.
3
Traverse nested array elements and primitives
For `ip-sla[0] -> stats -> history[1] -> rtt`, index `[1]` of `history` points to sample-id 2, returning `16`. For `ip-sla[1] -> stats -> history[0] -> success`, index `[0]` points to sample-id 1, returning `false`.
Properly indexing sub-arrays prevents off-by-one errors and identifies data types such as numbers vs. booleans.

Key Concept

Traversing nested JSON objects and zero-indexed arrays returned by Cisco REST APIs.
Rate this question