We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
serde_json example, but have checked the same problem occurs with serde_yaml:
#[derive(Serialize, Deserialize)] struct Unit; #[derive(Serialize, Deserialize)] enum UnitOrNot { Unit(Unit), NotUnit { field: String }, } #[derive(Serialize, Deserialize)] struct Nested { #[serde(flatten)] inner: UnitOrNot, } let data = r#" [ { "NotUnit": { "field": "value", "ignored": "bar" } }, { "Unit": { "ignored": "foo" } } ]"#; let _: Vec<Nested> = serde_json::from_str(data).unwrap();
The first element of the array successfully deserializes and ignores the extra "ignored" field. The second fails with:
Error: Error("invalid type: map, expected unit struct Unit", line: 11, column: 13)
(i.e. the extra field is now treated as belonging to the unit struct).
The code succeeds if you change the definition of Unit to
Unit
struct Unit {}
The text was updated successfully, but these errors were encountered:
ops::Module
No branches or pull requests
serde_json example, but have checked the same problem occurs with serde_yaml:
The first element of the array successfully deserializes and ignores the extra "ignored" field. The second fails with:
(i.e. the extra field is now treated as belonging to the unit struct).
The code succeeds if you change the definition of
Unit
toThe text was updated successfully, but these errors were encountered: