You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
600 B
20 lines
600 B
#[macro_use] extern crate serde_json;
|
|
#[macro_use] extern crate serde_derive;
|
|
|
|
#[derive(Serialize,Deserialize,Debug,Clone)]
|
|
struct Node {
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
name: Option<String>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
description: Option<String>,
|
|
#[serde(skip_serializing_if = "Vec::is_empty")]
|
|
children: Vec<Node>,
|
|
}
|
|
|
|
fn main() {
|
|
let source = include_str!("categories.json");
|
|
|
|
let parsed : Node = serde_json::from_str(source).expect("parse");
|
|
|
|
println!("{}", serde_json::to_string_pretty(&parsed).expect("serialize"));
|
|
}
|
|
|