Serializing object that contains cyclic object value

Use the second parameter of stringify, the replacer function, to exclude already serialized objects: var seen = []; JSON.stringify(obj, function(key, val) { if (val != null && typeof val == “object”) { if (seen.indexOf(val) >= 0) { return; } seen.push(val); } return val; }); http://jsfiddle.net/mH6cJ/38/ As correctly pointed out in other comments, this code removes … Read more