nerdexam
CiscoCisco

350-401 · Question #1344

350-401 Question #1344: Real Exam Question with Answer & Explanation

The correct answer is C: json_final = json.loads(json_data). Explanation json.loads(json_data) is the correct answer because the json.loads() function in Python is specifically designed to deserialize (parse) a JSON-formatted string into a Python dictionary/object, which is exactly what is needed when CLI output is returned as a raw string

Submitted by kwame.gh· Mar 6, 2026Automation

Question

Refer to the exhibit. As part of the preparation for network automation, a client network is deployed with on-box Python. The test script fails to convert the output type from a string value to an object. Which line of code enables the output to be printed in JSON object format?

Options

  • AFrom cli import json
  • Bcmd1 = 'show ip int brief | json'
  • Cjson_final = json.loads(json_data)
  • Dprint(json_final{"TABLE_intf"}{"ROW_intf"}(0}{"prefix"})

Explanation

Explanation

json.loads(json_data) is the correct answer because the json.loads() function in Python is specifically designed to deserialize (parse) a JSON-formatted string into a Python dictionary/object, which is exactly what is needed when CLI output is returned as a raw string and must be converted into a manipulable JSON object.

Why the distractors are wrong:

  • Option A (From cli import json) is syntactically incorrect Python - the proper syntax would be from cli import cli, and json is a separate standard library module imported independently.
  • Option B (cmd1 = 'show ip int brief | json') only appends the JSON flag to the CLI command to request JSON-formatted output, but it does not perform the conversion from string to object in Python.
  • Option D is a print statement using incorrect Python syntax (mixing {} and () for indexing), and even if corrected, it only displays a value - it doesn't perform the string-to-object conversion.

Memory Tip: Think of json.loads() as "load string" - the 's' stands for string, reminding you it converts a string → Python object, while json.dumps() does the reverse (object → string). If you need to convert CLI string output to a usable object, loads = string in.

Topics

#Python#JSON parsing#Data conversion#Network Automation

Community Discussion

No community discussion yet for this question.

Full 350-401 PracticeBrowse All 350-401 Questions