A network engineer issues an API call to a Cisco Catalyst Center endpoint to query site health metrics. The API returns the following JSON response payload stored in a Python dictionary named `site_data`:
{
"response": [
{
"siteHierarchy": "Global/USA/SanJose/Building1",
"clientCount": 150,
"healthScore": [
{
"healthType": "OVERALL",
"score": 88
},
{
"healthType": "WIRELESS",
"score": 92
}
]
}
]
}
Which Python expression correctly extracts the numerical score for the WIRELESS health type from `site_data`?
- site_data["response"][0]["healthScore"][1]["score"]Answer
- Bsite_data["response"][0]["healthScore"][0]["score"]
- Csite_data["response"]["healthScore"][1]["score"]
- Dsite_data["response"][0]["healthScore"]["WIRELESS"]["score"]
Answer
site_data["response"][0]["healthScore"][1]["score"]
The expression `site_data["response"][0]["healthScore"][1]["score"]` correctly traverses the data structure step by step: accessing the outer dictionary key "response", selecting the first element (index 0) of the response list, accessing the dictionary key "healthScore", selecting the second element (index 1) of the healthScore list which corresponds to WIRELESS, and finally retrieving the value for the key "score".
Step-by-Step Solution
Key Concept
Data extraction from nested JSON structures containing combinations of objects and arrays