Package Exports
- json-beautify
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json-beautify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
json-beautify
JSON.stringify with fixed maximum character width.
json-beautify is a fork of JSON.stringify json2.js implementation.
It has the exact same signature of JSON.stringify but it also adds an optional 4th parameter:
The maximum fixed character width (for instance 80).
Examples:
var beautify = require("json-beautify");
var obj = { str: "Hello World", num: 42, smallarray: [ 1, 2, 3, "foo", {} ], smallobject: { foo: "bar", bar: 42 }, bigarray: [ 1, 2, 3, "foo", { foo: "bar", bar: 42, arr: [ 1, 2, 3, "foo", {} ] } ], bigobject: { foo: [ 1, 2, 3, "foo", {} ], bar: 42, a: {b: { c: 42 }}, foobar: "FooBar" } };With 100 fixed-spaces:
console.log(beautify(obj, null, 2, 100));{
"str": "Hello World",
"num": 42,
"smallarray": [ 1, 2, 3, "foo", {} ],
"smallobject": { "foo": "bar", "bar": 42 },
"bigarray": [ 1, 2, 3, "foo", { "foo": "bar", "bar": 42, "arr": [ 1, 2, 3, "foo", {} ] } ],
"bigobject": { "foo": [ 1, 2, 3, "foo", {} ], "bar": 42, "a": { "b": { "c": 42 } }, "foobar": "FooBar" }
}With 80 fixed-spaces:
console.log(beautify(obj, null, 2, 80));{
"str": "Hello World",
"num": 42,
"smallarray": [ 1, 2, 3, "foo", {} ],
"smallobject": { "foo": "bar", "bar": 42 },
"bigarray": [
1,
2,
3,
"foo",
{ "foo": "bar", "bar": 42, "arr": [ 1, 2, 3, "foo", {} ] }
],
"bigobject": {
"foo": [ 1, 2, 3, "foo", {} ],
"bar": 42,
"a": { "b": { "c": 42 } },
"foobar": "FooBar"
}
}