Skip to content

Instantly share code, notes, and snippets.

@mroderick
Created April 15, 2015 10:20
Show Gist options
  • Save mroderick/2e00572af6a01e225fce to your computer and use it in GitHub Desktop.
Save mroderick/2e00572af6a01e225fce to your computer and use it in GitHub Desktop.
Readable output from JSON.stringify
var o = {hello:'world', greetings: ['one', 'two', 'three']};
undefined
// regular, difficult to read for large objects
JSON.stringify(o);
"{"hello":"world","greetings":["one","two","three"]}"
// presto!
JSON.stringify(o, '', ' ');
"{
"hello": "world",
"greetings": [
"one",
"two",
"three"
]
}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment