Exam 350-401 All QuestionsBrowse all questions from this exam
Question 855

DRAG DROP

-

Drag and drop the code snippets from the bottom onto the blanks in the script to convert a Python object into a compact JSON object by removing space characters. Not all options are used.

    Correct Answer:

Discussion
studying_1

I guess answer should be "dumps", data. separators If you have a Python object, you can convert it into a JSON string by using the json.dumps() method.

scarface35

given answer is wrong import json data = { "measurement":"cpmCPUTotal1minRev", "collectionInterval":"default", "tagCount":"0", "policy":None, "devices": [{"model":"cisco 3500 Series WLC","ipv4":"10.10.10.45"}] } obj=json.dumps(data,separators=(',', ':')) print(obj)

Shri_Fcb10

I thought CCNP is for Network Engineers not for automation Engineer

slacker_at_work

Code would indeed (as with the other comments below) look like: import json data = { "measurement": "cpmCPUTotallminRev", "collectionInterval": "default", "tagCount": "0", "policy": None, "devices": [{"model": "Cisco 3500 Series WLC", "ipv4": "10.10.20.52"}] } obj = json.dumps(data, separators=(',', ':')) <======= print(obj)

d4doppelganger

json.dumps(): used to serialize Python objects into a JSON formatted string json.loads(): used to deserialize a JSON formatted string into a Python object

SeMo0o0o

given answer is incorrect "dumps" - data - separators=(',', ':')

SeMo0o0o

......................

Alondrix

Given answer appears correct.