Demo entry 6349535

elm decoder

   

Submitted by anonymous on Feb 20, 2017 at 23:38
Language: Elm. Code size: 520 Bytes.

titleDetailDecoder : Decoder TitleDetail
titleDetailDecoder = map2 TitleDetail (field "titleNumber" int) (field "length" float)

titleDetailsList : Json.Decode.Decoder (List TitleDetail)
titleDetailsList =
  (field "titleDetails" string) |> 
    andThen 
      (\s ->
        decodeString (Json.Decode.list titleDetailDecoder) s |>
          (\result ->
            case result of 
              Ok xs -> Json.Decode.succeed xs
              Err err -> Json.Decode.fail <| err ++ "xx"
          )
      )

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).