-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: round-trip properly serde_json::Value #64
Conversation
Hm if you're using Can you confirm if it round-trip with that one? If it does, I'm a bit hesitant about accepting arbitrary objects and assuming they're maps in |
I can confirm that the test I just added in my latest commit does work out fine. In my specific case it does work out fine, because I'm not actually interacting with javascript and just sending stuff to indexeddb and back. So this should be fine for me, thank you! However, I still do think there is value in this PR: I would expect javascript objects to be a self-describing format, and most likely other object types would require self-describing formats for serialization. So I'll let this PR open and let you decide what you want to do with it. Anyway, this solves the immediate issue for me, so thank you! :) |
I can certainly see value, but the problem with allowing arbitrary classes is that the moment you add it, there's a lot more hidden complexity that you also need to add. For example, right now something like So now instead of And this all is just one example to demonstrate the can of worms that gets opened each time we want to implicitly accept a new type instead of erroring out :( |
Hmm I see the point :'( Should we then just white-list |
Maps and plain objects, so that we don't break structs. Yeah I think that's reasonable compromise. Maybe restore the previous code & comment and add Map check + extra comment to the same branch. |
Done with aeb2188 :) |
The case that led to me looking into this, is trying to round-trip through serde_wasm_bindgen a serde_json::Value that is a simple map.
I also added a test for round-tripping an array, but it looks like that test just passed without any changes.