JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4680
  • Score
    100M100P100Q116293F
  • License MIT

Stringify and format a JSON object

Package Exports

  • stringify-json-object

Readme

stringify-json-object

NPM TypeScript Coverage Status

Stringify and format a JSON object.

If I should maintain this repo, please ⭐️ GitHub stars

DM me on Twitter if you have questions or suggestions. Twitter


Installation

yarn add stringify-json-object
npm install stringify-json-object
pnpm add stringify-json-object

Usage

The stringify function works like JSON.stringify:

import stringify from "stringify-json-object";

stringify(true); // 'true'
stringify(1); // '1'
stringify("foo"); // '"foo"'
stringify({ foo: "bar" }); // '{"foo":"bar"}'
stringify({ foo: "bar", missing: undefined }); // '{"foo":"bar"}'

The stringify function also accepts an options argument, to easily format the output:

import stringify from "stringify-json-object";

stringify({ foo: "bar" }, { pretty: true }); // '{\n  "foo": "bar"\n}"

Additionally, primitives resolve to typed string literals:

import stringify from "stringify-json-object";

stringify(true); // "true"
stringify(1); // "1"
stringify("foo"); // "\"foo\""
stringify({ foo: "bar" }); // string

Dependenciesdependencies


Dev Dependencies

  • autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.

License license

MIT