Skip to content

serde De/Serializing Option<u64> fails #785

Closed as not planned
Closed as not planned
@jonaspleyer

Description

Hi,

I have some code in which I need to (de)-serialize in the following way:

#[test]
fn issue785() {
    #[derive(Debug, Deserialize, Eq, PartialEq, Serialize)]
    struct Identifier {
        parent: Option<u64>,
    }
    let ident = Identifier {
        parent: None,
    };
    let mut save_string = String::new();
    let mut serializer = quick_xml::se::Serializer::new(&mut save_string);
    serializer.indent(' ', 4);
    ident.serialize(serializer).unwrap();
    let res: Identifier = quick_xml::de::from_str(&save_string).unwrap();
    assert_eq!(res, ident);
}

This test does however fail with the current implementation of quick-xml. I have narrowed it down to the deserialize_option function of the MapValueDeserializer struct in src/de/map.rs. Sadly, I do not understand enough about the internals of quick-xml to contribute anything meaningful. Please let know how I can further help if needed.

PS: I have created a PR #786 to work on this problem.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    duplicateserdeIssues related to mapping from Rust types to XML

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions