Skip to content

Instantly share code, notes, and snippets.

@shaunhess
Created December 3, 2012 01:39
Show Gist options
  • Select an option

  • Save shaunhess/4192072 to your computer and use it in GitHub Desktop.

Select an option

Save shaunhess/4192072 to your computer and use it in GitHub Desktop.
Python - Pretty Printing JSON
>>> import json
>>> print(json.dumps(data)) # No indention
{"status": "OK", "count": 2, "results": [{"age": 27, "name": "Oz", "lactose_intolerant": true}, {"age": 29, "name": "Joe", "lactose_intolerant": false}]}
>>> print(json.dumps(data, indent=2)) # With indention
{
"status": "OK",
"count": 2,
"results": [
{
"age": 27,
"name": "Oz",
"lactose_intolerant": true
},
{
"age": 29,
"name": "Joe",
"lactose_intolerant": false
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment