How to prettyprint the JSON file in python?
Prettyprint is the application of any of the various stylistic formatting conventions to text files. such as source code, markup, and content. Prettyprint format is an indent parameter that specifies and the JSON module already implements. pretty-printing also works without explicit parsing: print json.dumps(json_data_string, indent=6)
.
json.dumps() converts a Python object into a json string.
#example import json json_data = '["data", {"details":["test1", "test2", 160, 168, 169]}]' parsed_data = json.loads(json_data) print(json.dumps(parsed_data, indent=6, sort_keys=True)) output : [ "data", { "details": [ "test1", "test2", 160, 168, 169 ] } ]