Closed hendore closed 7 years ago
Seems useful and reasonable. Would the "without" code benefit from Maybe.map encoder >> Maybe.withDefault Json.Encode.null
?
I think it's reasonable to include, it seems like a super common usecase and the parity with 0.18's Decode.nullable
is nice
@hendore would you mind changing the doc heading from # Oddly Shaped Values
to # Maybe
?
@mgold Nice, thats a very clever alternative.
@lukewestby Updated the heading, I just copied the # Oddly Shaped Values
from the core Decode module. https://github.com/elm-lang/core/blob/master/src/Json/Decode.elm#L35
Encode Maybe values as null if Nothing.
Without Json.Encode.Extra.maybe
With Json.Encode.Extra.maybe