Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1794

Recommended way to decode a JSON

$
0
0

For the record, rescript-json-combinators is very similar to elm-json, while also taking advantage of being written in rescript to make it significantly safer and more convenient in some (quite common) scenarios, such as decoding records.

Compare this decoder to the one above, for example:

  let decode = {
    open! Json.Decode
    object(field => {
      name: field.required("name", string),
      percent: field.required("percent", float),
      percentPer100K: field.required("percentPer100K", float),
    })
  }

Viewing all articles
Browse latest Browse all 1794

Trending Articles