JSPM

json-circular-stringify

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

Overrides JSON's stringify to handle circular references

Package Exports

  • json-circular-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-circular-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-circular-stringify

GitHub package.json version Build Status

Overrides JSON's stringify to handle circular references

Installation

npm i --save json-circular-stringify

Usage

require("json-circular-stringify");

// JSON.stringify() is now overridden at this point
// and you can use it as you normally would
// without minding circular references any longer

var obj = {name: "Alice"};
obj.self = obj;
var json = JSON.stringify(obj);

console.log(json); 

// Outputs '{"name":"Alice","self":"[Circular ~]"}'

Details

Makes use of json-stringify-safe but takes care of overriding JSON.stringify() itself. The original JSON.stringify() is renamed to JSON.origStringify() in case you missed it.