The Wayback Machine - https://web.archive.org/web/20220607054415/https://github.com/vorot93/node2object
Skip to content

vorot93/node2object

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 

node2object

GitHub Actions workflow status

Convert between XML nodes (treexml) and JSON objects (serde-json).

Example

extern crate treexml;

#[macro_use]
extern crate serde_json;

extern crate node2object;

fn main() {
    let dom_root = treexml::Document::parse("
        <population>
          <entry>
            <name>Alex</name>
            <height>173.5</height>
          </entry>
          <entry>
            <name>Mel</name>
            <height>180.4</height>
          </entry>
        </population>
    ".as_bytes()).unwrap().root.unwrap();
    
    assert_eq!(serde_json::Value::Object(node2object::node2object(&dom_root)), json!(
        {
          "population": {
            "entry": [
              { "name": "Alex", "height": 173.5 },
              { "name": "Mel", "height": 180.4 }
            ]
          }
        }
    )); 
}

About

Convert between XML Nodes (treexml::Element) and JSON objects (serde_json::Value)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages