Q:

Write a Python program to convert Python object to JSON data

0

Write a Python program to convert Python object to JSON data.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import json
# a Python object (dict):
python_obj = {
  "name": "David",
  "class":"I",
  "age": 6  
}
print(type(python_obj))
# convert into JSON:
j_data = json.dumps(python_obj)

# result is a JSON string:
print(j_data)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now