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
Xml #39
Xml #39
Conversation
First off this is awesome. I'll go through it tonight. Second, I was actually thinking about factoring json out into a separate crate as folks might not want json, or someone might come up with a better one down the road. What do you think? |
I've read about cargo having a few problems with multiple inheritance. Someone might be using |
Also: someone implementing a better/different json-deserializer won't have a conflict. During deserialization you choose which Deserializer to use; Rust doesn't care/know that two Deserializers deserialize the same format. |
bb73925
to
f6d2943
Compare
@erickt there are a few xml-specific things I'd like to discuss. Should I start a thread on the rust user forum or a wiki entry or an issue here? |
@oli-obk: Hi there! Sure, a thread would be wonderful. And in case you haven't noticed, I've been slowly pulling bits and pieces from your PR, so thanks for all the hard work so far! |
http://users.rust-lang.org/t/rfc-serde-xml-support/737 Yea I noticed, thanks. Although after merging Xml, some coverage checks would probably be good to figure out if I'm actually using all features I introduced. |
separating it out into its own crate isn't really working, and I don't know why:
|
What's the best way to play around with this pr? I'd like to parse this (http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml) and all necessary features should be inplace already... 👍 (I'm asking because the current version does not compile on either rust-1.0 beta nor the nightly…)
|
@nicolai86 it should work once rust-quasi is updated to master |
Updated to latest master and rustc nightly - https://github.com/hugoduncan/rust-serde/tree/oli-obk-xml |
@hugoduncan: I'm on it wrt skipping comments, version tags and similar. thanks for the rebase, I'll look into it |
I found I needed to strip I also needed to strip whitespace between tags to get input to parse. |
do you have an example that doesn't parse? I'll add it as a unit test. |
again, do you have examples and the expected behavior? I don't know much about xmlns :/ |
@oli-obk: an example string:
As a first iteration I think it is reasonable to just ignore |
I think xsd verification is out of scope of serde, but I might be wrong. Anyway, I can silently ignore it. |
your example string works now |
Another example. <?xml version="1.0" encoding="UTF-8"?>
<DescribeVpcsResponse xmlns="http://ec2.amazonaws.com/doc/2014-10-01/">
<requestId>8d521e9a-509e-4ef6-bbb7-9f1ac0d49cd1</requestId>
<vpcSet>
<item>
<vpcId>vpc-ba0d18d8</vpcId>
<state>available</state>
</item>
</vpcSet>
</DescribeVpcsResponse> |
@erickt: I think I need to extend serde with "fixed size sequences" to get sequences of sequences to work. http://users.rust-lang.org/t/rfc-serde-xml-support/737/9 |
@hugoduncan actually this is already possible: let s = r#"
<?xml version="1.0" encoding="UTF-8"?>
<DescribeVpcsResponse xmlns="http://ec2.amazonaws.com/doc/2014-10-01/">
<requestId>8d521e9a-509e-4ef6-bbb7-9f1ac0d49cd1</requestId>
<vpcSet>
<item>
<vpcId>vpc-ba0d18d8</vpcId>
<state>available</state>
</item>
</vpcSet>
</DescribeVpcsResponse>"#;
#[derive(PartialEq, Debug, Serialize, Deserialize)]
#[allow(non_snake_case)]
struct Item {
vpcId: String,
state: String,
}
#[derive(PartialEq, Debug, Serialize, Deserialize)]
struct Helper {
item: Vec<Item>,
}
#[derive(PartialEq, Debug, Serialize, Deserialize)]
#[allow(non_snake_case)]
struct DescribeVpcsResponse {
requestId: String,
vpcSet: Helper,
}
test_parse_ok(&[
(
s,
DescribeVpcsResponse {
requestId: "8d521e9a-509e-4ef6-bbb7-9f1ac0d49cd1".to_string(),
vpcSet: Helper { item: vec![ Item {
vpcId: "vpc-ba0d18d8".to_string(),
state: "available".to_string(),
}]},
},
),
]); |
This would also give you the (in my opinion) expected |
@oli-obk: Would you like to land this in a https://github.com/serde-rs repo? |
@erickt sounds like a plan. a separate crate should speed up compilation quite a bit. |
closed in favor of https://github.com/oli-obk/serde-xml |
would you be so kind as to review the
serde_macros
andDeserializer
changes?current state:
<anytagname>value</anythingelse>
&abcd;
)anti-features (just ignoring stuff I don't like):
things that would be nice to have but might not be possible