Hi,
I was decoding an http response (body can be blank) and realized that
Decode fails on empty string. Gives the error "Given an invalid JSON:
Syntax error". Is this by design or a bug?
import Html exposing (text)
import Json.Decode as Decode exposing (..)
main =
text <| toString test
test =
[ succeed "cool"
, fail "oh"
, null "what?"
]
|> List.map (flip decodeString "")
If it is by design, what is the recommended way of decoding string that can
be blank.
For now, I'm using
let
x' =
if x == "" then "\"\"" else x
in
case decodeString decoder x' of
...
regards,
Richard.
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.