I’m new to Elm and learning it! It’s very cool!
I have a question and I want to have some feedback, thanks!
Take the example from here: How to decode complex JSON with Elm? // Tech @ ChefClub //
type alias Record =
{ uid : String
, age : Maybe Int
, version : Float
}
customDecoder : JD.Decoder Record
customDecoder =
decode Record
|> required "uid" JD.string
|> optional "age" (JD.maybe JD.int) Nothing
|> hardcoded 1.0
I’m wondering why field names sometimes appear in the decoder, and sometimes don’t?
If the field name is good for readability, why the usage here is not
customDecoder =
decode Record
|> required "uid" JD.string
|> optional "age" (JD.maybe JD.int) Nothing
|> hardcoded "version" 1.0
If the parameter order is enough, then why the usage here is not
customDecoder =
decode Record
|> required JD.string
|> optional (JD.maybe JD.int) Nothing
|> hardcoded 1.0
I’m wondering if there’s an inconsistency API design issue in JSON decoder here …?
Thanks for any feedback!