krakenjs / post-robot

Cross domain post-messaging on the client side using a simple listener/client pattern.
Apache License 2.0
745 stars 91 forks source link

Serializing circular objects and toJSON #77

Open doublemarked opened 5 years ago

doublemarked commented 5 years ago

I'm using post-robot via zoid, passing an object back to my parent via a callback function. This object contains a circular reference deep within it, but I've implemented a toJSON() method on the class containing the reference in order to support serialization.

This object can be happily serialized with JSON.stringify(), but it breaks when post-robot serializes it. I believe post-robot isn't calling my toJSON() method, it's walking the object itself and follows the circular reference to its doom.

Please advise?

doublemarked commented 5 years ago

Hey @bluepnume any thoughts on this issue? Maybe you can advise on a fix? I can probably find time to work on a PR

ddenev commented 4 years ago

+1