How to implement custom indentation when pretty-printing with the JSON module?
(Note: The code in this answer only works with json.dumps() which returns a JSON formatted string, but not with json.dump() which writes directly to file-like objects. There’s a modified version of it that works with both in my answer to the question Write two-dimensional list to JSON file.) Updated Below is a version of my … Read more