[javascript] Serializing object that contains cyclic object value

I have an object (parse tree) that contains child nodes which are references to other nodes.

I'd like to serialize this object, using JSON.stringify(), but I get

TypeError: cyclic object value

because of the constructs I mentioned.

How could I work around this? It does not matter to me whether these references to other nodes are represented or not in the serialized object.

On the other hand, removing these properties from the object when they are being created seems tedious and I wouldn't want to make changes to the parser (narcissus).

This question is related to javascript json jsonserializer stringify

The answer is


Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to json

Use NSInteger as array index Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) HTTP POST with Json on Body - Flutter/Dart Importing json file in TypeScript json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) Angular 5 Service to read local .json file How to import JSON File into a TypeScript file? Use Async/Await with Axios in React.js Uncaught SyntaxError: Unexpected token u in JSON at position 0 how to remove json object key and value.?

Examples related to jsonserializer

error CS0234: The type or namespace name 'Script' does not exist in the namespace 'System.Web' Jackson enum Serializing and DeSerializer Serializing object that contains cyclic object value Cannot find JavaScriptSerializer in .Net 4.0 Ruby objects and JSON serialization (without Rails)

Examples related to stringify

Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) Convert javascript object or array to json for ajax data JSON.stringify output to div in pretty print way how to use JSON.stringify and json_decode() properly Serializing object that contains cyclic object value