Skip to content Skip to sidebar Skip to footer

How To Solve ' Uncaught Typeerror: Converting Circular Structure To Json '

Im executing a webpage but it displaying following error while checking it on Console. 'Uncaught TypeError: Converting circular structure to JSON' console.log(JSON.stringify(physi

Solution 1:

This happens when you have a circular reference between objects.

For example:

A references BB references A

When you try and serialize A then it needs to serialize B, but then it needs to serialize A again and there is no way to represent that loop in JSON. The result would be an infinite recursive loop.

You need to identify and remove the circular references. Remember that the chain can be more complex than the above:

A references BB references C
C references A

It doesn't matter how many links there are or how they are stored. If you can go from one object to another object and then back to the first one by any route then it is a circular reference.

Solution 2:

JSON can't contain circular references (do you know what a circular reference is?)

You'll need to reformat your data structure to avoid them before serializing.

Post a Comment for "How To Solve ' Uncaught Typeerror: Converting Circular Structure To Json '"