Circular
Tiny utility to safely stringify objects with circular references.
Usage
Replace all circular references with the string [Circular]
;
var circular = ;var obj = {}; var child = parent: obj; objchild = child;var str = JSON;// => {"child":{"parent":"[Circular]"}}
If you prefer you can pass an alternative string to use:
var str = JSON;
Or a function that returns a string:
{return '' + value};var str = JSON;
As of version 1.0.4
you can also pass an additional boolean that will convert function references to strings, useful for converting javascript modules to couchdb
design documents.
var str = JSON;