How to decode JSON object with more than 8 fields?

261 views
Skip to first unread message

Petr Huřťák

unread,
Aug 1, 2016, 8:21:24 AM8/1/16
to Elm Discuss
For 8 fields or less I can do

import Json.Decode as Decode exposing ((:=))

collectionDecoder : Decode.Decoder (List Test)
collectionDecoder =
    Decode.list
        (Decode.object8 Test
            ("id" := Decode.int)
            ...
        )


How to decode JSON object with more than 8 fields?

Peter Damoc

unread,
Aug 1, 2016, 8:28:53 AM8/1/16
to Elm Discuss

--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
There is NO FATE, we are the creators.
blog: http://damoc.ro/

Aditya Vishwakarma

unread,
Aug 1, 2016, 11:11:04 AM8/1/16
to Elm Discuss
If you wish to know how to do it, then take a look at this : https://github.com/adityav/elm-reddit-listing/blob/master/src/Decoders.elm#L14

Once you understand how it is done, you can use http://package.elm-lang.org/packages/NoRedInk/elm-decode-pipeline/1.1.2 package. 

Pablo Parga

unread,
Aug 1, 2016, 3:58:35 PM8/1/16
to Elm Discuss
This is a great tool to encode/decode : http://noredink.github.io/json-to-elm/
Reply all
Reply to author
Forward
0 new messages