Answers for "python pprint json"

11

python print pretty json

import json

json_data = '[{"ID":10,"Name":"Pankaj","Role":"CEO"},' \
            '{"ID":20,"Name":"David Lee","Role":"Editor"}]'

json_object = json.loads(json_data)

json_formatted_str = json.dumps(json_object, indent=2)

print(json_formatted_str)
Posted by: Guest on April-30-2020
3

python format json file

python3 -m json.tool unformatted.json > formatted.json
Posted by: Guest on June-09-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language