0085. JSON null decodes to the outer option none
- Status: Accepted; clarifies ADR-0083's JSON option rule
- Date: 2026-11-01
- Plan: M9.6 Step 6.5
- Review: Data, schemas and wire formats
Context
ADR-0083 represents option none as JSON null and newtypes as
their representation. For option<optiontests/programs/codec-json-encode-shapes already pins
option<option
Decision
Decode null as the outer option's none, including through
transparent newtypes. Keep the existing encoder output, which
deliberately includes nested options in the Step 6.3
codec-json-encode-shapes golden. Non-null input
decodes recursively as some(payload). Document that some(none)
normalizes to none; an explicit enum is needed when the
distinction matters. No compiler or existing golden output changes
are needed.
Alternatives considered
- Reject option<option
> at generation time and update — removes the ambiguity but breaks existing accepted encoder programs and their pinned shape coverage.codec-json-encode-shapes - Tag nested options — changes the null-based wire rule and introduces a second option representation before there is a schema-evolution design.
Consequences
Required keys and null-as-none remain consistent at every nesting level. Nested options are not injective on the JSON wire, as already true of their encoders; tests pin the normalization. A future alternative representation needs a new decision; binary option tags are unaffected.