Skip to content

Instantly share code, notes, and snippets.

@Marwes
Created September 29, 2018 13:36
Show Gist options
  • Save Marwes/d1e709e0322b608c6735fc29c530cf00 to your computer and use it in GitHub Desktop.
Save Marwes/d1e709e0322b608c6735fc29c530cf00 to your computer and use it in GitHub Desktop.
Gluon code shared from try_gluon
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