1.1.1 • Published 5 years ago

json-beautify v1.1.1

Weekly downloads
20,142
License
ISC
Repository
github
Last release
5 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-1983ep_mypadsemuto-clienapso-swaggeremc-interaction-formatteremc-interactionsemc-interactions2endpoint-monitorescala-core-libdiaporama-makerdevbugdependency-injection-catdirectory-module-webpack-plugincy-report-setup-helpercertainty-jscoderslang-cli@slate-editor/state-loggercomptrollerdashboard-goodfooddawn-interfacestemperaezchartsswagger-editor-biswagger-editor-binaryswagger-editor-npm-packagefros-transformfudge-clikiali-uij_binj_utilswp-bridgezqb-npm-publish-testgenprojectvue-podvue-skutil-datamodelgitlab-ci-monitoring-dashboardgitlab-ci-v4-dashboardgitlab-ci-dashboardgl-react-inspectorgenerator-jive-react-addongenerator-stenciljstsdx_mylib_tempgoetiaunit-clihandy-storagexsdlibraryipbcrawleritstimeironman-clivisual-expressvoiceflow@iqdavidh/factoryreqjsonmail-all-emlsmulticryptowalletneu2neighborhood-outlineskradanlunchladymahendrabagul@haixing_hu/common-util@handstudio/envmanldx-lineup@gsmlg/ui5-webcomponents-tools@janus-idp/backstage-plugin-kialimr-jdbmr-mdb@kiali/kiali-uimulti-formatter@kebian/fontawesome-free-metadatamoleculateln3scanlogkslogiks@joegesualdo/get-youtube-subtitle-url-nodemockeroni@reborndevelopers/design-system-toolbox@euglena/script@euglena/cli@pie-framework/pie-demo@pddstudio/docker-manifestnuarca-cloud-utils@pittankopta/vibranium@pioneer-platform/fio-crypto@pioneer-platform/fio-networkpackmerger@mindee/web-elements@neushimmer/joipear-avax-cli
1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

9 years ago

1.0.0

9 years ago