serde_indextree
Serializing indextree
structure.
Version support
indextree version |
serde_indextree version |
---|---|
3.3.x | 0.1.x |
4.0.x | 0.2.x |
Usage
serde_indextree
provides two struct: Node
for serializing
a node and its descendants, SiblingNodes
for serializing a
node and its siblings in sequence.
use Arena;
use Serialize;
use Node;
use to_string_pretty;
// <html>
// <head>
// <title></title>
// <head>
// <body>
// <h1></h1>
// <h2></h2>
// </body>
// </html>
let arena = &mut new;
let a = arena.new_node;
let b = arena.new_node;
a.append;
let c = arena.new_node;
b.append;
let d = arena.new_node;
a.append;
let e = arena.new_node;
d.append;
let f = arena.new_node;
d.append;
println!;
// {
// "tag": "html",
// "children": [
// {
// "tag": "head",
// "children": [
// {
// "tag": "title"
// }
// ]
// },
// {
// "tag": "body",
// "children": [
// {
// "tag": "h1"
// },
// {
// "tag": "h2"
// }
// ]
// }
// ]
// }
Customization
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.
License
MIT