haskell / aeson

A fast Haskell JSON library
Other
1.25k stars 321 forks source link

Optional fields #1039

Closed phadej closed 1 year ago

phadej commented 1 year ago

Continuation of #1023

phadej commented 1 year ago

I was thinking Aeson could retain backwards compatibility

It's not worth it. There are barely any direct users of these https://hackage-search.serokell.io/?q=liftToJSON and arguably the ones who are (e.g. autocodec, insert-ordered-containers, should adapt and could adapt easily).

EDIT: In fact liftToJSONOmit _ = liftToJSON would make generic deriving "wrong" by default. The same problem as with toEncoding: people (e.g. yourself) forget to define it. The current design of toEncoding = toEncoding . toJSON makes doing wrong thing easy for the sake of backward compatibility which is moot now about a decade ago. This is an example while I'd just break things right away, instead of waiting indefinitely for people to start doing the right thing.

friedbrice commented 1 year ago

@phadej That all makes a lot of sense. Thanks for explaining the situation to me. (Also, I'll start defining toEncoding!)