Normal JSON.stringify fails to serialize objects if it contains Circular References. In this library, I have tried to show how you can Decycle an object with circular references that can be serialized using JSON.stringify. Using this library you can also fully restore the object structure given that you have the same environment as when you serialized it. I will show you below what I mean.

This library takes care of Arrays and null references properly. Using this library you can also fully restore the object structure given that you have the same environment as when you serialized it. I will show you below what I mean.

Above code throws the following error,

Uncaught TypeError: Converting circular structure to JSON