Merge pull request #112 from ephraimkunz/same-child-name
Fix bug where nested structs with the same element names don't deserialize properly.
This commit is contained in:
commit
a8ef1358a9
@ -1072,6 +1072,5 @@ fn de_same_field_name_but_some_other_fields_or_something() {
|
||||
};
|
||||
|
||||
serialize_and_validate!(model, content);
|
||||
// TODO fix it
|
||||
// deserialize_and_validate!(content, model, FooOuter);
|
||||
deserialize_and_validate!(content, model, FooOuter);
|
||||
}
|
||||
|
||||
@ -373,16 +373,23 @@ pub fn parse(
|
||||
);
|
||||
match event {
|
||||
::xml::reader::XmlEvent::StartElement{ref name, ref attributes, ..} => {
|
||||
match name.local_name.as_str() {
|
||||
#call_visitors
|
||||
_ => {
|
||||
let event = reader.next_event()?;
|
||||
#write_unused
|
||||
if depth == 0 && name.local_name == #root {
|
||||
// Consume root element. We must do this first. In the case it shares a name with a child element, we don't
|
||||
// want to prematurely match the child element below.
|
||||
let event = reader.next_event()?;
|
||||
#write_unused
|
||||
} else {
|
||||
match name.local_name.as_str() {
|
||||
#call_visitors
|
||||
_ => {
|
||||
let event = reader.next_event()?;
|
||||
#write_unused
|
||||
|
||||
if depth > 0 { // Don't skip root element
|
||||
reader.skip_element(|event| {
|
||||
#write_unused
|
||||
})?;
|
||||
if depth > 0 { // Don't skip root element
|
||||
reader.skip_element(|event| {
|
||||
#write_unused
|
||||
})?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user