Support decoding of undefined record field to Nothing
jvliwanag opened this issue · 1 comments
jvliwanag commented
Is your change request related to a problem? Please describe.
Can we support optional fields to Maybe? In particular, treat undefined values as Nothing.
Both should be decode to { a: Nothing }
{}{"a": null}
Describe the solution you'd like
I propose adding a new
class DecodeJsonField a where
decodeJsonField :: Maybe Json -> Maybe (Either JsonDecodeError a)
and using it within the decoding.
I am also of the opinion of encoding Nothing should encode to an undefined field - but that can be a separate matter.
jvliwanag commented
Note that this behavior aligns more with typical JSON based web api's, allowing us to use simple record types for such.