Skip to content

Support decoding of undefined record field to Nothing #92

Closed
@jvliwanag

Description

@jvliwanag

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions