You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on https://serde.rs/attr-flatten.html#capture-additional-fields and example usage in #1179 I assumed that having a flattened other: HashMap<String, Value> at the end of a struct to be deserialized into will always return us unknown fields. In the above example, deserializing into OuterWithExtra gives us all fields that are supplied in the JSON, while also setting a and b correctly. This doesn't seem like the desired behavior?
If we don't have nested #[serde(flatten)] it behaves as expected. See playground.
I was exploring this as a way to detect unknown fields after finding that serde_ignored doesn't work with #[serde(flatten)]: dtolnay/serde-ignored#10
The text was updated successfully, but these errors were encountered:
Based on https://serde.rs/attr-flatten.html#capture-additional-fields and example usage in #1179 I assumed that having a flattened
other: HashMap<String, Value>
at the end of a struct to be deserialized into will always return us unknown fields. In the above example, deserializing intoOuterWithExtra
gives us all fields that are supplied in the JSON, while also settinga
andb
correctly. This doesn't seem like the desired behavior?If we don't have nested
#[serde(flatten)]
it behaves as expected. See playground.I was exploring this as a way to detect unknown fields after finding that
serde_ignored
doesn't work with#[serde(flatten)]
: dtolnay/serde-ignored#10The text was updated successfully, but these errors were encountered: