Skip to content

kbaylosis/json-circular-stringify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Overrides JSON's stringify to handle circular references

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published