Skip to content

mlevkov/xmlJSON-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xmlJSON

Crates.io Crates.io Crates.io Build Status

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

Status

Docs

Usage

Add this to your Cargo.toml:

[dependencies]
xmlJSON = "0.2.0"

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

About

Rust Crate for converting XML to JSON

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%