Q:

Write a Python program to convert Python dictionary object (sort by key) to JSON data. Print the object members with indent level 4

0

Write a Python program to convert Python dictionary object (sort by key) to JSON data. Print the object members with indent level 4. 

All Answers

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

import json
j_str = {'4': 5, '6': 7, '1': 3, '2': 4}
print("Original String:")
print(j_str)
print("\nJSON data:")
print(json.dumps(j_str, sort_keys=True, indent=4))

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