-
-
Save cobalamin/342fe97b21eb7f81c2a3055183c14fc5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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