-
Notifications
You must be signed in to change notification settings - Fork 236
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
Deserializing to variant vector fields fails #288
Comments
Derive a test from tafia#288
I hit this error as well. I added a test case ( It fails with:
|
I correctly understand, that #387 addresses those problems? If not, please try to reduce your example and turn it into the Rust testcase |
I have 0.36.1 and I'm still hitting this error. I have this example: use serde_derive::Deserialize;
#[test]
fn show_bug() {
let xml = r###"
<?xml version='1.0' encoding='UTF-8'?>
<Root>
<Entry type="Foo">
<Datum value="asdf"/>
</Entry>
<Entry type="Bar">
<Datum value="qwer"/>
<Datum value="zxcv"/>
</Entry>
</Root>
"###;
#[derive(Debug, Deserialize)]
struct Root {
#[serde(rename = "Entry")]
entries: Vec<Entry>,
}
#[derive(Debug, Deserialize)]
#[serde(tag = "@type")]
enum Entry {
Foo {
#[serde(rename = "Datum")]
datum: Datum,
},
Bar {
#[serde(rename = "Datum")]
data: Vec<Datum>
}
}
#[derive(Debug, Deserialize)]
struct Datum {
#[serde(rename = "@value")]
value: String,
}
let root: Root = quick_xml::de::from_str(xml).unwrap();
} which fails with |
@albx79, this is because bufferisation step that internally tagged enums introduces. During bufferisation content of <Entry type="Bar">
<Datum value="qwer"/>
<Datum value="zxcv"/>
</Entry> read into private serde's type Map {
@type = String(Bar),
Datum = Map {
@value = String(qwer),
},
Datum = Map {
@value = String(zxcv),
},
} It is stored buffered as However, we try to deserialize a This situation could be improved in two ways:
|
Example with tagged and untagged enums showing different errors. The tagged error seems to point to the source of the issue.
The text was updated successfully, but these errors were encountered: