Debian Codegraph @

examples/transcode.rs

raw symbols SCIP
1 use ron::value::Value;
2 use serde::Serialize;
3
4 fn main() {
5 let data = r#"
6 Scene( // class name is optional
7 materials: { // this is a map
8 "metal": (
9 reflectivity: 1.0,
10 ),
11 "plastic": (
12 reflectivity: 0.5,
13 ),
14 },
15 entities: [ // this is an array
16 (
17 name: "hero",
18 material: "metal",
19 ),
20 (
21 name: "monster",
22 material: "plastic",
23 ),
24 ],
25 )
26 "#;
27
28 let value: Value = data.parse().expect("Failed to deserialize");
29 let mut ser = serde_json::Serializer::pretty(std::io::stdout());
30 value.serialize(&mut ser).expect("Failed to serialize");
31 }