I am writing a JSON decoder for elm (0.19.1). My incoming json Value is an empty object {}. How can I decode that value to a type (here NoPayload)?
I tried to decode it with the help of JD.string decoder:
JD.string
|> JD.andThen
(\str ->
if str == "{}" then
JD.succeed NoPayload
else
JD.fail "Failed to decode non-empty payload to NoPayload decoder"
)
But that resulted in an error:
Problem with the given value:
{}
Expecting a STRING
Alternatively, I am experimenting with JD.null and JD.dict, but I cannot find a solution.