Saving dict as JSON so that they are human readable

Viewed 3616

When a dict is saved using json.dump, it is only a single-line. I want to make this a human-readable format such as this website does - https://jsonformatter.curiousconcept.com

How can I do this in python? I tried to capture pprint output, but it is an invalid string to store JSON in.

Specifically, is there an acceptable default way to do this in python directly?

1 Answers
Related