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-ui@arnongpmc/donttouchpleasethanks@aliens-lyon.fr/ep_mypads@aljesusg/backstage-plugin-kiali@cfwest/macro-controller@1doc3/hermes-chat@coon-js/deloreanxsdlibraryzqb-npm-publish-testvue-podvue-skutil-datamodelunit-clitsdx_mylib_temp@gsmlg/ui5-webcomponents-tools@handstudio/envman@haixing_hu/common-util@fjdr/react-diagrams-gallery@edusorcer/itstime@edusorcer/tacker@euglena/cli@euglena/script@iqdavidh/factoryreqjson@neushimmer/joi@mindee/web-elements@janus-idp/backstage-plugin-kiali@joegesualdo/get-youtube-subtitle-url-node@kiali/kiali-ui@kebian/fontawesome-free-metadata@reborndevelopers/design-system-toolbox@pie-framework/pie-demo@northbrook/util@pittankopta/vibranium@pioneer-platform/fio-crypto@pioneer-platform/fio-network@skypilot/sugarbowl@skypilot/scraper@slate-editor/state-logger@seatbelt/coremulti-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-dashboard
1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

10 years ago

1.0.0

10 years ago