Skip to content

Instantly share code, notes, and snippets.

@gladimdim
Last active December 18, 2017 12:04
Show Gist options
  • Save gladimdim/d2c9404215b94c82148e416b6758b5b1 to your computer and use it in GitHub Desktop.
Save gladimdim/d2c9404215b94c82148e416b6758b5b1 to your computer and use it in GitHub Desktop.
Decoding JSON maybe undefined properties
type metricCount = {type_: string};
type metricWithLabel = {
type_: string,
label: string
};
let createCountWithLabel = (label: string) : metricWithLabel => {type_: "COUNT", label};
let countMetric: metricCount = {type_: "COUNT"};
let transformToCount20 = (oldJson) => {
let label = Json.Decode.(oldJson |> optional(field("label", string)));
// to be implemented
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment