Skip to content

Instantly share code, notes, and snippets.

@reactormonk
Created August 6, 2016 10:42
Show Gist options
  • Save reactormonk/d24299f1c923a97f41d161bcbcaf6957 to your computer and use it in GitHub Desktop.
Save reactormonk/d24299f1c923a97f41d161bcbcaf6957 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 Encode.int obj.a)
, ("b", Maybe.withDefault Encode.null Encode.string obj.b)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment