Pretty-Print JSON Using JSON.stringify()
Did you know that JSON.stringify() takes additional parameters?
JSON.stringify(myObj, null, 4);
This will pretty-print your stringified JSON object using 4 spaces for indentation. The second parameter is a "replacer" param that determines what is kept or removed from the final string.
Written by Jason Edelman
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#