JSPM

json-stringify

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

Enhanced JSON.stringify

Package Exports

  • json-stringify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json-stringify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

json-stringify NPM version Build Status Dependency Status

Enhanced JSON.stringify

Install

$ npm install json-stringify --save

Usage

var stringify = require('json-stringify');
var array = [1, '2'];

stringify(array, {
  indent: 2,
  offset: 4
});

You will get

[
------1,
------"2"
----]

So, if we have an template

{
  "foo": <bar>,
  "foo2": <bar2>
}

And there's an object obj

var bar = stringify({
  bee: 'boo'
}, {
  indent: 2,
  offset: 2
});

var bar2 = JSON.stringify({
  bee: 'boo'
}, null, 2);

var obj = {
  bar: bar,
  bar2: bar2
};

And the renderered result is:

{
  "foo": {
    "bee": "boo"
  },
  "foo2": {
  "bee": "boo"
}
}

You must found the difference.

Licence

MIT