serde_indextree
Serializing indextree
structure.
| indextree
version | serde_indextree
version |
|---------------------|---------------------------|
| 3.3.x | 0.1.x |
| 4.0.x | 0.2.x |
serde_indextree
provides two struct: Node
for serializing
a node and its descendants, SiblingNodes
for serializing a
node and its siblings in sequence.
```rust use indextree::Arena; use serde::Serialize; use serdeindextree::Node; use serdejson::tostringpretty;
struct HtmlElement { tag: &'static str }
// //
//println!("{}", tostringpretty(&Node::new(a, arena)).unwrap()); // { // "tag": "html", // "children": [ // { // "tag": "head", // "children": [ // { // "tag": "title" // } // ] // }, // { // "tag": "body", // "children": [ // { // "tag": "h1" // }, // { // "tag": "h2" // } // ] // } // ] // } ```
Unfortunately, serde_indextree
doesn't come up with any customization.
If you want to rename field names or anything, just copy the entire code (only 40+ lines) and modify it at your wish.
MIT