-
Notifications
You must be signed in to change notification settings - Fork 17
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
Numbers and &str deserialization fails #5
Comments
Could you provide an isolated test case I could compile/run that fails? Note that deserializing to See also the smoke test for an example usage that as far as I know does deserialize and serialize a u32 properly, that might give us something to compare against. |
I don't have it easily accessible right now, but IIRC I was triyng to parse the output of wpa_supplicant's status command ( |
By "it failed" are you getting a particular error? Not sure what's going on, what you have there should be equivalent to what's done internally... I'm not able to run that command, could you attach some example output? |
I ran into the same issue and can provide a simple test setup. https://github.com/Larusso/serde-ini-fail-example/blob/master/src/lib.rs This example is derived from some experimentation I do at the moment. If you run the tests you will see that the test For a better visibility here are the three structs: #[derive(Deserialize, Debug)]
#[serde(rename_all = "PascalCase")]
pub struct Data {
#[serde(default, skip_serializing_if = "Option::is_none")]
section_1: Option<Box<FieldData>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
section_2: Option<Box<FieldData>>,
#[serde(default, skip_serializing_if = "Option::is_none")]
section_3: Option<Box<FieldData>>,
}
#[derive(Deserialize, Debug)]
#[serde(transparent)]
pub struct Data2(HashMap<Keys,FieldData>);
#[derive(Deserialize, Debug)]
#[serde(rename_all = "PascalCase")]
pub struct Data3 {
section_1: FieldData,
#[serde(flatten)]
components: HashMap<Keys, FieldData>,
} All three tests in this sample setup use the same struct: I hope this helps you |
Hm, that looks like an issue with the new Given that |
Hmm maybe. I am still somewhat new to Rust and the cargo ecosystem and have no idea what feature is new and which crate is older etc :) |
Hm yeah, no need to add more information but you can just use the "Open New Issue" button next to your comment. There's an issue with how |
I was trying to deserialize a u64 and noticed it was failing, even though strings and other objects were working fine. There didn't seem to be any problem with the text being deserialized:
id=61
So I tried making a workaround to investigate:
However this failed, so I eventually tried using a full String
This works, but obviously involves a heap allocation that would seem to be unnecessary.
Regardless, without this workaround, the typical behavior is that integers and real numbers of all types seem to fail.
The text was updated successfully, but these errors were encountered: