Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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)
- Host: GitHub
- URL: https://github.com/vorot93/node2object
- Owner: vorot93
- License: mit
- Created: 2017-02-06T20:39:13.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-12-21T02:07:11.000Z (almost 5 years ago)
- Last Synced: 2024-10-11T01:15:00.391Z (about 1 month ago)
- Topics: json, xml, xml2json
- Language: Rust
- Homepage:
- Size: 17.6 KB
- Stars: 7
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: COPYING
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 }
]
}
}
));
}
```