Skip to content
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

json_compatible Deserializer #54

Closed
ranile opened this issue Aug 29, 2023 · 1 comment
Closed

json_compatible Deserializer #54

ranile opened this issue Aug 29, 2023 · 1 comment

Comments

@ranile
Copy link

ranile commented Aug 29, 2023

serde_wasm_bindgen::Serializer::json_compatible exists but there is no equivalent for Deserializer.

let date = js_sys::Date::new_0();
let object = js_sys::Object::new();
js_sys::Reflect::set(&object, &"date".into(), &date).unwrap();
gloo::console::log!(&object);
let value: serde_json::Value = serde_wasm_bindgen::from_value(object.into()).unwrap();
gloo::console::log!(format!("{value:?}"));

This logs:
image

I would like there to be a way to deserialize a date somehow.

@RReverser
Copy link
Owner

Well you can't deserialize a date from JSON into a Date object because JSON doesn't know anything about those higher-level types, so the deserializer is still compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants