I have an array of nodes.
Each node has an array of children and a pointer to its parent.
I would like to serialize it using JSON.stringify, but with the parent pointers I obviously end up with circular references, and JSON throws an exception. What can I do to work-around the circular references and serialize with JSON?
Related question: Chrome sendrequest error: TypeError: Converting circular structure to JSON
You should create a customized toJson function in the objects that have parents.
From the documentation
So you could create that function in the objects that have parent references, something like this maybe?