Posts tagged with “json”

Outputing human friendly JSON string with JSON.stringify

method 1:

JSON.stringify(obj, null, '\t');

This "pretty-prints" your JSON string, using a tab for indentation.

method 2:

If you prefer to use spaces instead of tabs, you could also use a number for the number of spaces you'd like :

JSON.stringify(obj, null, 2);

Reference