Skip to content
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

How to deserialize an element contains empty string? #795

Closed
jianse opened this issue Aug 9, 2024 · 1 comment
Closed

How to deserialize an element contains empty string? #795

jianse opened this issue Aug 9, 2024 · 1 comment
Labels
serde Issues related to mapping from Rust types to XML

Comments

@jianse
Copy link

jianse commented Aug 9, 2024

#[derive(Debug, Deserialize)]
struct Text {
    #[serde(rename = "$value")]
    text: String,
}

#[test]
fn test_de() -> Result<()> {
    let xml = r#"<Text> </Text>"#;
    let txt: Text = quick_xml::de::from_str(xml)?;
    let txt = dbg!(txt);
    assert_eq!(txt.text, " ");
    Ok(())
}

expect an write space, but gives an error.

Error: missing field `$value`
@Mingun
Copy link
Collaborator

Mingun commented Aug 9, 2024

Whitespaces between markup is not significant and currently that cannot be changed. #285 tracks the ability to change that.

Closed as duplicate of #285

@Mingun Mingun closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2024
@Mingun Mingun added the serde Issues related to mapping from Rust types to XML label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
serde Issues related to mapping from Rust types to XML
Projects
None yet
Development

No branches or pull requests

2 participants