Skip to content

Instantly share code, notes, and snippets.

@oisinkim
Created September 5, 2013 11:13
Show Gist options
  • Select an option

  • Save oisinkim/6448824 to your computer and use it in GitHub Desktop.

Select an option

Save oisinkim/6448824 to your computer and use it in GitHub Desktop.
What to do when JSON.stringify returns cyclic object value
var obj = something;
var res = JSON.stringify(obj, function(key, val) {
if (typeof val == "object") {
if (seen.indexOf(val) >= 0)
return;
seen.push(val)
}
return val;
})
console.log(res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment