Last active
July 18, 2018 21:19
-
-
Save rippinrobr/4ef27bc5725b90e7981a78722c0fc1bb to your computer and use it in GitHub Desktop.
Elm Category type alias and the decode function for a category JSON object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type alias Category = { | |
id : Int | |
,name : String | |
,approved : Int | |
} | |
-- categoryDecoder is the code that pulls the data out of the JSON object | |
-- and creates a Category object | |
categoryDecoder : Decoder Category | |
categoryDecoder = | |
map3 Category | |
(field "id" int) | |
(field "name" string) | |
(field "approved" int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment