300-435 · Question #115
Refer to the exhibit. Cisco SD-WAN deployment must be fixed using vManage APIs. A call to vEdge Hardware Health API returns the data in the exhibit (only a portion is shown). If the JSON shown in…
The correct answer is C. d['data'][0]['statusList'][0]['status']. To access the "status" property nested within the first element of the statusList array, which itself is inside the first element of the data array of a Python dictionary d, the correct reference is d['data'][0]['statusList'][0]['status'].
Question
{
"data": [
{
"count": 4,
"detailsURL": "",
"name": "vEdge Hardware Health",
"status": "error",
"statusList": [
{
"count": 4,
"detailsURL": "/dataservice/device/hardwarehealth/detail?state=normal',
"message": "4 (normal=4, warning=0, error=0)",
"name": "normal",
"status": "up"
}
]
}
]
}
Options
- Ad['data'][0]['statusList']["status"]
- Bnbvnbvvnbhg
- Cd['data'][0]['statusList'][0]['status']
- Dd['data'][0]['statusList'][0]['status']
How the community answered
(38 responses)- A3% (1)
- B5% (2)
- C89% (34)
- D3% (1)
Why each option
To access the "status" property nested within the first element of the `statusList` array, which itself is inside the first element of the `data` array of a Python dictionary `d`, the correct reference is `d['data'][0]['statusList'][0]['status']`.
This attempt incorrectly tries to access 'status' directly from the 'statusList' list itself, rather than from an element *within* the list, which would result in a TypeError because a list cannot be indexed by a string key like 'status'.
"nbvnbvvnbhg" is clearly a random string and not a valid Python dictionary reference.
The JSON structure shows "data" as a list, so `d['data'][0]` accesses its first element. Within that element, "statusList" is another list, so `d['data'][0]['statusList'][0]` accesses its first element. Finally, `['status']` accesses the "status" key within that nested dictionary, which holds the value "up".
This choice is syntactically identical to option C and would also be correct, but typically only one choice is the intended answer in a multiple-choice question format.
Concept tested: Python dictionary and list indexing for JSON parsing
Topics
Community Discussion
No community discussion yet for this question.