1
2import json
3
4json_data = '[{"ID":10,"Name":"Pankaj","Role":"CEO"},' \
5 '{"ID":20,"Name":"David Lee","Role":"Editor"}]'
6
7json_object = json.loads(json_data)
8
9json_formatted_str = json.dumps(json_object, indent=2)
10
11print(json_formatted_str)
12
1import json
2
3# alphabetic dictionary
4json_data = {hex(k): chr(k) for k in range(ord('a'), ord('z') + 1)}
5# to file
6with open("my_json.json", "w") as file:
7 json.dump(json_data, file, indent=4, sort_keys=True)
8