CCNP 350-401 ENCOR Question 478 DISCUSSION

  • 1496 views
  • 2023-07-01
« Back to Main Menu

Which line must be added in the Python function to return the JSON object {“cat_9k”:”FXS193202SE”)?

Q478

A. 
return (json.dumps({d[‘hostname’]: d[‘serialNumber’] for d in json.loads(test_json)[‘response’]}))
B. 
return (json.loads({for d in json.dumps(test_json)[‘response’]: d[‘hostname’]: d[‘serialNumber’]}))
C. 
return (json.loads({d[‘hostname’]: d[‘serialNumber’] for d in json.dumps(test_json)[‘response’]}))
D.
 return (json.dumps({for d in json.loads(test_json)[‘response’]: d[‘hostname’]: d[‘serialNumber’]}))

Which line must be added in the Python function to return the JSON object {“cat_9k”:”FXS193202SE”)?

Q478

A. 
return (json.dumps({d[‘hostname’]: d[‘serialNumber’] for d in json.loads(test_json)[‘response’]}))

B. 
return (json.loads({for d in json.dumps(test_json)[‘response’]: d[‘hostname’]: d[‘serialNumber’]}))
C. 
return (json.loads({d[‘hostname’]: d[‘serialNumber’] for d in json.dumps(test_json)[‘response’]}))
D.
 return (json.dumps({for d in json.loads(test_json)[‘response’]: d[‘hostname’]: d[‘serialNumber’]}))

Correct Answer: A

Support AceITCert.com by buying stuff you need!

1 Comments

ohhhvictor

json.load method parse a valid JSON string and convert it into a Python dictionary. the test_json variable is a JSON string so the answers that use json.dumps(test_json) are incorrect. Out of the other two, answer A is valid.

 

json.loads function for string to object. json.dumps function for object to string. question for return object. Keyword = dumps D for D.

2024-04-25 15:59:14
In order to participate in the comments you need to be logged-in.
You can sign-up or login (it's free).