Skip to content

Trap "toJSON" to allow serialization of proxies #31

Open
@CheloXL

Description

@CheloXL

Hi,
I just found an issue while trying to store objects on IDB. It seems that IDB can't serialize proxied objects, and throws an error (Serialization error: Can't serialize [object object] on xxx...).

So, in order for me to be able to store these objects, I have to serialize/deserialize the object manually (so effectively removing the proxy).

I was thinking that maybe you can trap the checks for "has toJSON" to return true and then when that method is invoked, return the raw object. That would solve the serialization issue.

If the object already has a toJSON method, you should not have to do anything.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions