Organisationsahrefsatd0fc67a

atdml: add <json repr="object"> for sum types (externally-tagged encoding) (#486) Tagged variants are now encoded as single-key JSON objects {"Constructor": payload} when the sum type is annotated with <json repr="object">. Unit variants remain "Constructor" strings. This matches Serde's externally-tagged representation. Both of_yojson and of_jsonlike readers are generated. The yojson writer (yojson_of_*) also produces the object encoding. Implementation: - atd/src/json.ml,mli: new json_sum_repr = Array | Object type and field on json_sum; get_json_sum reads <json repr="object"> - atdml Codegen.ml: new sum_object_tagged_pat mode field for the pattern strings; gen_reader and gen_yojson_of switch on json_sum_repr - atdgen/src/oj_emit.ml: fill new json_sum_repr field (Array) in one hand-constructed json_sum literal - Support matrix: new "Sum as JSON object" feature row (atdml=Yes, all others=Planned) Closes #479 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

Mar 30 18:49 +00:00
1m14s
*Variants labelled (experimental) are still undergoing testing; if they have failed it may be a bug in OCaml-CI.