Any plans to support circular structures?
Judahh opened this issue · comments
Judah Holanda Correia Lima commented
Juan Dopazo commented
Hi @Judahh, unless I'm mistaken I believe the only way to support them would be to create a new protocol and a new "parse" method. That would go a bit past what I think the original design goal was (to be able to just eval
the serialized result).
undefined commented
I think its possible to serialize as the following:
(() => {
const t = {}; // some base structure
t.foo = t; // do some magic
return t;
})();
This becomes a little bit tricky, and I don't know is this feature really needed in most use cases.
Emile commented
I made a tool that does what serialize-javascript does, but also added support for circular references, duplicate objects and more:
https://github.com/emilesonneveld/serialize-to-js