I have a complex (nested) json text file that is one long line in the text file
Is there any way to read in the file (in python) and indent / pretty-print the json to a
Yes, you can use open() to read/write file, then json.load() to read the file and json.dump(..., indent=4) to pretty-print it.
Read the file using json.load(..)
, and use json.dump(..)
to write the object out to another file while specifying indent value.
with open("inFile") as f, open("outFile", "w") as g:
json.dump(json.load(f), g, indent=4)