Skip to content

Instantly share code, notes, and snippets.

@wohali
Last active January 26, 2018 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wohali/3a5f7d96ec2ad24c1e976adc1fb71f49 to your computer and use it in GitHub Desktop.
Save wohali/3a5f7d96ec2ad24c1e976adc1fb71f49 to your computer and use it in GitHub Desktop.
json pretty printer in python
#!/usr/bin/env python
# (C) 2017 wohali
#
# I don't give a fuck about how this will be used. Everything will be allowed, including changing the name, citing wrongly, claiming ownership and destroying the computer. You are allowed to do anything with this as long as:
#
# 0. I don't give a fuck.
# 1. You agree that you don't give a fuck.
# 2. You agree that your use of this will have nothing to fuck with me now and in the future.
# 3. You don't fuck me legally/illegally.
#
# As long as you agree with these terms, you are free to do fucking anything, whether legal or not legal in your country, because I don't give a fuck. If you don't agree with my terms, fuck off.
#
# That's all, now do what the fuck you want.
import json
with open("filename", "r") as f:
data = json.load(f)
with open("filename-pprint.json", "w") as f:
json.dump(data, f, indent=2)
@ellieayla
Copy link

cat filename | python -m json.tool > filename-ppprint.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment