javascript pretty print code example
Example 1: JSON.stringify pretty
var str = JSON.stringify(obj, null, 2); // spacing level = 2
Example 2: js json stringfy beutify
JSON.stringify(obj, undefined, 2);
Example 3: javascript print object pretty
//Prototype JSON.stringify(value[, function [, space]])
var myObject = {"hello": "world", "!": []};
var str = JSON.stringify(myObject, null, '\t');//space may be a string or a number corresponding to the number of space
//What is displayed in the console
{
"hello": "world",
"!": []
}