Crates.io | xmlJSON |
lib.rs | xmlJSON |
version | 0.2.0 |
source | src |
created_at | 2015-05-16 18:01:47.530199 |
updated_at | 2017-03-07 20:17:07.226947 |
description | Conversions from XML to JSON |
homepage | http://sacooper.github.io/xmlJSON-rs/xmlJSON/index.html |
repository | https://github.com/sacooper/xmlJSON-rs |
max_upload_size | |
id | 2120 |
size | 25,986 |
Convert XML data to JSON. Note that this is not yet well tested. Use at your own risk.
Add this to your Cargo.toml:
[dependencies]
xmlJSON = "0.1.3"
Structs for conversions from XML to JSON
extern crate xmlJSON;
extern crate rustc_serialize;
use xmlJSON::XmlDocument;
use rustc_serialize::json;
use std::str::FromStr;
let s = "<test lang=\"rust\">An XML Document <testElement>A test
element</testElement></test>"
let document : XmlDocument = XmlDocument::from_str(s).unwrap();
let jsn : json::Json = document.to_json();
The resulting Json will be of the form
{
"test": {
"$": {
"lang": "rust"
},
"_" : "An Xml Document",
"testElement": {
"_" : "A test element"
}
}
}
and add this to your crate root:
extern crate xmlJSON;
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.