“too much recursion” error when calling JSON.stringify on a large object with circular dependencies
问题 I have an object that contains circular references, and I would like to look at the JSON representation of it. For example, if I build this object: var myObject = {member:{}}; myObject.member.child = {}; myObject.member.child.parent = myObject.member; and try to call JSON.stringify(myObject); I get the error "too much recursion", not surprisingly. The "child" object has a reference to its "parent" and the parent has a reference to its child. The JSON representation does not have to be