1
0
Fork 0
firefox/third_party/rust/ron/examples/transcode.rs
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

31 lines
855 B
Rust

use ron::value::Value;
use serde::Serialize;
fn main() {
let data = r#"
Scene( // class name is optional
materials: { // this is a map
"metal": (
reflectivity: 1.0,
),
"plastic": (
reflectivity: 0.5,
),
},
entities: [ // this is an array
(
name: "hero",
material: "metal",
),
(
name: "monster",
material: "plastic",
),
],
)
"#;
let value: Value = data.parse().expect("Failed to deserialize");
let mut ser = serde_json::Serializer::pretty(std::io::stdout());
value.serialize(&mut ser).expect("Failed to serialize");
}