Skip to content

Instantly share code, notes, and snippets.

@hshoff
Last active August 29, 2015 14:01
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 hshoff/360f0cf9015422986780 to your computer and use it in GitHub Desktop.
Save hshoff/360f0cf9015422986780 to your computer and use it in GitHub Desktop.
Pretty print objects with JSON.stringify
function print(obj) {
console.log(JSON.stringify(obj, null, 2));
};
print({one:1,two:[{name:'charles',label:'barkley'},{name:'han',label:'solo'}]};
// {
// "one": 1,
// "two": [
// {
// "name": "charles",
// "label": "barkley"
// },
// {
// "name": "han",
// "label": "solo"
// }
// ]
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment