Tutorial by Examples

The following example can be tested on https://ellie-app.com/m9tk39VpQg/0. import Html exposing (..) import Json.Decode payload = """ ["fu", "bar"] """ main = Json.Decode.decodeString decoder payload -- Ok ["fu","b...
The following examples can be tested on https://ellie-app.com/m9vmQ8NcMc/0. import Html exposing (..) import Json.Decode payload = """ [ { "bark": true, "tag": "dog", "name": "Zap", "playful": true } , { "w...
This is useful if you use rust in the backend and elm on the front end enum Complex{ Message(String), Size(u64) } let c1 = Complex::Message("hi"); let c2 = Complex::Size(1024u64); The encoded Json from rust will be: c1: {"variant": "Message", ...
The following code can be found in a demo here: https://ellie-app.com/mbFwJT9jD3/0 import Html exposing (..) import Json.Decode exposing (Decoder) payload = """ [{ "id": 0, "name": "Adam Carter", "work": "Uni...
In case you have json with an ISO date string like this JSON.stringify({date: new Date()}) // -> "{"date":"2016-12-12T13:24:34.470Z"}" You can map it to elm Date type: import Html exposing (text) import Json.Decode as JD import Date payload = ""&...
See Ellie for a working example. This example uses the NoRedInk/elm-decode-pipeline module. Given a list of JSON objects, which themselves contain lists of JSON objects: [ { "id": 0, "name": "Item 1", "transactions": [ { "id&quo...

Page 1 of 1