pretty-json-stringify
A naive function that adds customizeable indents to JSON data (pretty-prints JSON whitespace). You can define whether any object or array should either be collapsed to one line or expanded with one item on each line.
Syntax
var JSONString = ;
Example
var prettyJSONStringify = ; ;
This returns
Also following "code-style" parameters can be applied (any passed string is inserted as is, it is user's responsibility to keep it valid whitespace):
tab
(default: 4 spaces)spaceBeforeColon
(default: 1 space)spaceAfterColon
(default: 1 space)spaceAfterComma
(default: 1 space)spaceInsideObject
(inserted after opening and before closing braces, default: 1 space)spaceInsideArray
(inserted after opening and before closing braces, default: empty string).
If shouldExpand
parameter is not passed, it expands every object whose plain JSON is longer that 25 characters.