nerdexam
Cisco

350-401 · Question #852

Based on the router's API output in JSON format below, which Python code will display the value of the "role" key? A. B. C. D.

The correct answer is B. json_data = response.json() print(json_data['response'][0]['role']). Option B is correct because response.json() is the proper Requests library method to parse a JSON response directly into a Python dictionary, and json_data['response'][0]['role'] correctly navigates the JSON structure where 'role' is a direct key within the first element of the '

Submitted by ashley.k· Mar 6, 2026Software Development and Design – Consume REST-based APIs using Python scripts to interact with network infrastructure APIs (e.g., Cisco DNA Center / DNAC)

Question

Based on the router's API output in JSON format below, which Python code will display the value of the "role" key? A. B. C. D.

Exhibits

350-401 question #852 exhibit 1
350-401 question #852 exhibit 2

Options

  • Ajson_data = json.loads(response.text) print(json_data['response'][0]['family']['role'])
  • Bjson_data = response.json() print(json_data['response'][0]['role'])
  • Cjson_data = response.json() print(json_data['response'][0]['family']['role'])
  • Djson_data = json.loads(response.text) print(json_data['response'][0]['role'])

How the community answered

(55 responses)
  • A
    7% (4)
  • B
    75% (41)
  • C
    15% (8)
  • D
    4% (2)

Explanation

Option B is correct because response.json() is the proper Requests library method to parse a JSON response directly into a Python dictionary, and json_data['response'][0]['role'] correctly navigates the JSON structure where 'role' is a direct key within the first element of the 'response' list. The JSON structure shows 'role' at the top level of the response object, not nested inside a 'family' key.

Topics

#Python#REST API#JSON Parsing#Requests Library

Community Discussion

No community discussion yet for this question.

Full 350-401 Practice