Categories
Pretty print JSON in Python (snippet)
The below depends on the json Python module to 'pretty print' JSON output in Python. I found this useful when trying to write my script to remove unused Todoist labels.
import json
# This function saves time printing JSON nicely
def pj(str):
print(json.dumps(json.loads(str.content), indent=4))
return
pj(thing_containing_raw_json_here)
Note that in my case this was contingent on having used the requests module in the following fashion to already make sure the format is a bit jsonified, Read more [...]