Closed sffc closed 1 year ago
Normally when you deserialize something like
{ "a": 1 }
into a Serde struct like
#[derive(Deserialize)] struct Foo { a: Option<String>, b: Option<String>, }
the deserialization succeeds, putting a None into the b field. However, if I apply deserialize_with = deserialize_option_number_from_string to that field, then I get an error that the field b is missing.
None
b
deserialize_with = deserialize_option_number_from_string
CC @younies
I see, it seems the field needs to be annotated with #[serde(default)].
#[serde(default)]
Normally when you deserialize something like
into a Serde struct like
the deserialization succeeds, putting a
None
into theb
field. However, if I applydeserialize_with = deserialize_option_number_from_string
to that field, then I get an error that the fieldb
is missing.CC @younies