Open mdashti opened 7 years ago
This is expected. You should use #[serde(deserialize_with=foo)]
and
fn foo<'de, D>(d: D) -> Result<T, D::Error> where D: Deserializer<'de> {
let s = String::deserialize(d)?;
match &s[..] {
"true" => Ok(true),
"false" => Ok(false),
other => Err(D::Error::custom(format!("got {}, but expected `true` or `false`", other))),
}
}
@oli-obk Should this work with the next version.
No. This is a can of worms that we do not want to open (see https://github.com/RReverser/serde-xml-rs/pull/18). We can offer the function foo
as a convenience function though, since this seems to be a common issue.
I though of this test https://github.com/RReverser/serde-xml-rs/blob/master/tests/migrated.rs#L342-L349
Huh? How is that test passing?
So it works as a root element but not a field?
Something like <test bla="true"></test>
should also work, but <test bla></test>
shouldn't work currently
The rust-s3 project was apparently working fine before and could parse this xml:
<ListBucketResult
xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>RelationalAI</Name>
<Prefix>/</Prefix>
<KeyCount>0</KeyCount>
<MaxKeys>1000</MaxKeys>
<IsTruncated>true</IsTruncated>
</ListBucketResult>
But, it does not work now, and it might be because of some recent changes in your codebase.
@mdashti serde-xml-rs definitely didn't support that format, it's rather because it switched from serde-xml to serde-xml-rs in rust-s3 in https://github.com/durch/rust-s3/commit/2f684e28b8750fb9b5ea44572c95935d918d73f7
Hi all,
I have the following (minimized) program:
And the result of running it is:
I am using rustc 1.20.0 (f3d6973f4 2017-08-27) and my sample project is in test_proj.zip.
Can anyone help me to solve the issue?