Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vorot93/node2object

Convert between XML Nodes (treexml::Element) and JSON objects (serde_json::Value)
https://github.com/vorot93/node2object

json xml xml2json

Last synced: 17 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# node2object

[![GitHub Actions workflow status](https://github.com/vorot93/node2object/workflows/Continuous%20integration/badge.svg)](https://github.com/vorot93/node2object/actions)

Convert between XML nodes ([treexml](https://github.com/rahulg/treexml-rs)) and JSON objects ([serde-json](https://github.com/serde-rs/json)).

## Example
```
extern crate treexml;

#[macro_use]
extern crate serde_json;

extern crate node2object;

fn main() {
let dom_root = treexml::Document::parse("


Alex
173.5


Mel
180.4


".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 }
]
}
}
));
}
```