| 1 | use ronrust-analyzer cargo ron 0.12.0 crate/::valuerust-analyzer cargo ron 0.12.0 value/::Valuerust-analyzer cargo ron 0.12.0 value/Value#; |
| 2 | use serderust-analyzer cargo serde 1.0.228 crate/::Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#; |
| 3 | |
| 4 | fn mainrust-analyzer cargo ron 0.12.0 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: Valuerust-analyzer cargo ron 0.12.0 value/Value# = data.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to deserialize"); |
| 29 | let mut ser = serde_jsonrust-analyzer cargo serde_json 1.0.60 crate/::Serializerrust-analyzer cargo serde_json 1.0.60 ser/Serializer#::prettyrust-analyzer cargo serde_json 1.0.60 ser/impl#[`Serializer<W, PrettyFormatter<'a>>`]pretty().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/stdout().()); |
| 30 | value.serializerust-analyzer cargo ron 0.12.0 ser/value/impl#[Value][Serialize]serialize().(&mut ser).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to serialize"); |
| 31 | } |