aeson
aeson copied to clipboard
Option nullaryToObject to encode/decode nullary constructors as empty objects
issue #925
- [x] Generic JSON/encoding/parse
- [x] TH JSON/encoding/parse
- [x] with rejectUnknownFields option, non-empty objects should fail (both Generic and TH
- [x] tests
- [x] make parsers dependent on the option, without relaxing the default behaviour
I've figured how to add this option to TH encoding, and added tests... For TH parsing, I suspect parseNullaryMatches
should change but don't yet understand how...
cc @phadej
@phadej I think it's mergeable, and it would be great if we could upstream it - as I wrote, you can't use the library with Swift without this option.
Parsing for nullary constructors currently accepts both empty array and an object (object must be empty if rejectUnknownFields is set), so it will parse JSON generated irrespective of this option.