Skip to content

Instantly share code, notes, and snippets.

@cobalamin
Forked from reactormonk/Codec.elm
Last active August 6, 2016 10:48
Show Gist options
  • Save cobalamin/342fe97b21eb7f81c2a3055183c14fc5 to your computer and use it in GitHub Desktop.
Save cobalamin/342fe97b21eb7f81c2a3055183c14fc5 to your computer and use it in GitHub Desktop.
module Codec exposing (..)
import Json.Encode as Encode
type alias Listy =
{ a : List Int, b : Maybe String }
encodeListy : Listy -> Encode.Value
encodeListy obj =
Encode.object
[ ( "a", Encode.list (List.map Encode.int obj.a) )
, ( "b", Maybe.withDefault Encode.null (Maybe.map Encode.string obj.b) )
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment