aeson icon indicating copy to clipboard operation
aeson copied to clipboard

Decode null to ()

Open domenkozar opened this issue 6 years ago • 3 comments

Sometimes you always expect null in a certain field and it would be great if that could get decoded to ().

domenkozar avatar Dec 12 '19 13:12 domenkozar

See discussion in https://github.com/bos/aeson/issues/542

phadej avatar Dec 12 '19 13:12 phadej

Would it be then acceptable to add another unit type to aeson? Currently I have to use Maybe () which is confusing.

domenkozar avatar Dec 12 '19 13:12 domenkozar

Proxy () encodes to / decodes from null

phadej avatar Dec 12 '19 13:12 phadej

Since this issue had been opened we changed () instance so it accepts everything.

To clarify, @domenkozar do you want to check that the field is exactly null. Have you tried Proxy anything, or would you prefer having data Null = Null in aeson?

phadej avatar Jun 19 '23 08:06 phadej

Both work for my use case.

domenkozar avatar Jun 19 '23 08:06 domenkozar

Ok. Then I don't think we need to anything. We'll keep data Null = Null idea, but that can be added at anytime if there's really good reasoning.

phadej avatar Jun 19 '23 08:06 phadej