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-expressvoiceflow@bunpmjs/bunext@pddstudio/docker-manifestitstimej_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@iqdavidh/factoryreqjson@1doc3/hermes-chat@gsmlg/ui5-webcomponents-tools@handstudio/envman@haixing_hu/common-util@edusorcer/itstime@edusorcer/tacker@coon-js/delorean@aljesusg/backstage-plugin-kiali@aliens-lyon.fr/ep_mypads@cotester-ai/cli@cfwest/macro-controllerxsdlibraryzqb-npm-publish-testvue-podvue-skutil-datamodelunit-clitsdx_mylib_temp@neushimmer/joi@kiali/kiali-ui@kebian/fontawesome-free-metadata@reborndevelopers/design-system-toolbox@pie-framework/pie-demo@pittankopta/vibranium@pioneer-platform/fio-crypto@pioneer-platform/fio-network@seatbelt/coremulti-formattermulticryptowalletmr-jdbmr-mdbmoleculatemockeronipackmergeroccs-widget-wizardnuarca-cloud-utilsnwkopear-avax-clipdf-markdownscreeps-performance-serversequelize-migreatreact-drabneu2neighborhood-outlinespie-demopretty-json-file-formatterricemoodredstone-smartweave-exp
1.1.1

6 years ago

1.1.0

7 years ago

1.0.1

10 years ago

1.0.0

10 years ago