Read-only record fields and default values in JSON parser
Closed this issue · 2 comments
adamgundry commented
At present, the read-only flag and defaults on record fields are not made use of by the generated FromJSONWithErrs
instances; instead, application code must apply a separate preprocessing step on the JSON values. Defaults, at least, could be implemented in the generated parsers.
Read-only fields are slightly more tricky, as we sometimes need to ignore them (when parsing data from client requests) and sometimes need to read them (when deserialising), so the parser type would need to be extended with mode information.
cdornan commented
What modes would we need?
adamgundry commented
At the moment, the parser would just have to pass around a boolean flag indicating whether to ignore read-only fields.