KhaledMaged KhaledMaged - 1 year ago 79
JSON Question

What is the type of a JSON object in python?

I'm new to JSON. I have a dictionary, I convert it to a JSON object using

myJsonObject = json.dumps(myDictionary)

But then If I check the type, I get
<type 'str'>

Is string is the expected output for a JSON object?

PS: Python 2.7

Update: How can I get a JSON type, if dumps is not the correct way?

Answer Source

Of course, this is called "Serialization" - you are dumping a Python data structure into a JSON formatted string:


Serialize obj to a JSON formatted str using this conversion table.

If you load a JSON string with loads(), this would be "deserialization" and you would get a Python list or a dictionary.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download