5 releases

Uses old Rust 2015

0.2.0 Feb 14, 2016
0.1.3 Dec 20, 2015
0.1.2 Sep 4, 2015
0.1.1 May 16, 2015
0.1.0 May 16, 2015

#18 in #json-xml

Download history 33/week @ 2024-03-11 10/week @ 2024-03-18 30/week @ 2024-04-01 5/week @ 2024-04-08 7/week @ 2024-04-15 9/week @ 2024-04-22 5/week @ 2024-04-29 2/week @ 2024-05-06 10/week @ 2024-05-13 9/week @ 2024-05-20 12/week @ 2024-05-27 9/week @ 2024-06-03 3/week @ 2024-06-10 7/week @ 2024-06-17 12/week @ 2024-06-24

100 downloads per month

MIT/Apache

14KB
286 lines

xmlJSON

Convert XML data to JSON. Note that this is not yet well tested. Use at your own risk.

Status

Build Status

Docs

Usage

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;

License

Licensed under either of

at your option.

Contribution

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.

TODO:

  • Add better testing
  • Add documentation
  • Add conversion from JSON to XML, and allowing for writing JSON as XML

Dependencies

~625KB
~13K SLoC