Created
September 29, 2018 13:36
-
-
Save Marwes/d1e709e0322b608c6735fc29c530cf00 to your computer and use it in GitHub Desktop.
Gluon code shared from try_gluon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let de @ { Deserialize, ? } = import! std.json.de | |
let ser @ { Serialize, ? } = import! std.json.ser | |
let { Result } = import! std.result | |
#[derive(Serialize, Deserialize)] | |
type Vec = { x : Float, y : Float, name : Option String } | |
match de.deserialize de.deserializer r#"{ "x": 123, "y": 456.78, "name": null }"# with | |
| Err err -> err | |
| Ok v -> | |
let v : Vec = v | |
let updated = { x = v.x, y = v.y, name = Some "Vector" } | |
match ser.to_string_pretty updated with | |
| Err err -> err | |
| Ok s -> s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment