Skip to content

Instantly share code, notes, and snippets.

@amitaibu
Created September 2, 2015 18:30
Show Gist options
  • Save amitaibu/26fed3040f8664ff36db to your computer and use it in GitHub Desktop.
Save amitaibu/26fed3040f8664ff36db to your computer and use it in GitHub Desktop.
import Graphics.Element exposing (show)
import Json.Decode as Json exposing ((:=))
-- MODEL
type alias Model =
{ id: Int
, label: String
}
serialized : String
serialized = "{\"id\":1,\"label\":\"foo\"}"
decoder : Json.Decoder Model
decoder =
Json.object2 Model
("id" := Json.int)
-- Notice instead of label we have a "wrongKey"
("wrongKey" := Json.string)
main =
show (Json.decodeString decoder serialized)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment