Answers for "python json.dumps indent=4"

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
0

python dump json with indent

json.dumps(parsed, indent=4, sort_keys=True)
Posted by: Guest on July-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language