1.1.1 • Published 6 years ago

json-beautify v1.1.1

Weekly downloads
20,142
License
ISC
Repository
github
Last release
6 years ago

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"
  }
}
nodejs-jwt-authorizationreact-mindeeqester-cli@spokedev/zolareact-drab-cliiconman-cli@cfwest/api@mindee/react-web-essentials@lsby/code_english_translation@iqdavidh/libfront@codeshinobi-dk/or-monorepo@infinitebrahmanuniverse/nolb-json-b@everything-registry/sub-chunk-1983aic-fbswagger-editorswagger-editor-biswagger-editor-binaryswagger-editor-npm-packagewp-bridgetemperavisual-expressvoiceflowitstimej_binj_utilsironman-cliipbcrawlerkiali-uihandy-storageinspecterldx-lineuplogikslunchladylogksmahendrabagulmail-all-emlsln3scankradan@thorstensuckow/delorean@ui5/webcomponents-tools@tuval/forms@temporalio/ui@tprox/cp-json@usearcade/arcade-libs@up9/mizu-commonads-token-genaminoseeapim-swagger-editorapim-swagger-editor-casapim-swagger-editor-gas@gsmlg/ui5-webcomponents-tools@handstudio/envman@haixing_hu/common-utilxsdlibraryzqb-npm-publish-testvue-podvue-skutil-datamodelunit-clitsdx_mylib_tempmulti-formattermulticryptowalletmr-jdbmr-mdbmoleculatemockeronipackmergeroccs-widget-wizardnuarca-cloud-utilsnwkopear-avax-clipdf-markdownscreeps-performance-serversequelize-migreatreact-drabneu2neighborhood-outlinespie-demopretty-json-file-formatterricemoodredstone-smartweave-expramuhsimple-dependencies-updaterreact-stagessmartweavesmartweave-vertosmtliblibsimple_mockersnapshot-creatorsketch-jsongoetiagitlab-ci-dashboardgitlab-ci-monitoring-dashboardgitlab-ci-v4-dashboardgl-react-inspector@northbrook/util@pddstudio/docker-manifest@fjdr/react-diagrams-gallery@pittankopta/vibranium@pioneer-platform/fio-crypto@pioneer-platform/fio-network
1.1.1

6 years ago

1.1.0

7 years ago

1.0.1

10 years ago

1.0.0

10 years ago