Open vorner opened 7 years ago
It seems when using the internally tagged enums, the deserializer gets somewhat confused. If I have this code:
#[derive(Deserialize)] #[serde(tag = "z")] enum Z { A { b: String }, B { c: String }, } #[derive(Deserialize)] struct X { y: Z, } let x = br#"<x><y z="A"><b>hello</b></y></x>"#; serde_xml_rs::deserialize::<_, X>(Cursor::new(x)).unwrap();
it produces this error:
invalid type: map, expected a string
I believe this should actually work. This code does work:
#[derive(Deserialize)] struct Z { z: String, b: String, } #[derive(Deserialize)] struct X { y: Z, } let x = br#"<x><y z="A"><b>hello</b></y></x>"#; serde_xml_rs::deserialize::<_, X>(Cursor::new(x)).unwrap();
I know the internally-tagged thing is a bit weird in XML, but I actually discovered it in real-life (parsing the conntrack XML output).
Any idea how to fix it? @oli-obk
Not really. Maybe a trace gives some insights?
It seems when using the internally tagged enums, the deserializer gets somewhat confused. If I have this code:
it produces this error:
I believe this should actually work. This code does work:
I know the internally-tagged thing is a bit weird in XML, but I actually discovered it in real-life (parsing the conntrack XML output).