You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
542 B
27 lines
542 B
module Participant exposing (Participant, decoder)
|
|
|
|
import Json.Decode exposing (Decoder, field, map2, string)
|
|
import Json.Encode as Enc exposing (object)
|
|
|
|
|
|
type alias Participant =
|
|
{ id : String
|
|
, name : String
|
|
}
|
|
|
|
|
|
decoder : Decoder Participant
|
|
decoder =
|
|
map2 Participant
|
|
(field "id" string)
|
|
(field "name" string)
|
|
|
|
|
|
encode : Participant -> String
|
|
encode participant =
|
|
object
|
|
[ ( "id", Enc.string participant.id )
|
|
, ( "name", Enc.string participant.name )
|
|
]
|
|
|> Enc.encode 0
|