You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
atdd: add <json repr="object"> for sum types (externally-tagged encoding) (#490)
* atdd: add <json repr="object"> for sum types
Tagged variants are encoded as single-key JSON objects
{"Constructor": payload} instead of the default two-element array
["Constructor", payload]. This matches the default Rust/Serde
externally-tagged encoding. It also reads naturally in YAML as a
single-key mapping, which is one motivation for the feature.
Unit variants (no payload) are always encoded as plain strings
regardless of the repr annotation.
The D associative-array literal ["key": value] is used for encoding.
The decoder checks JSONType.object_, accesses the sole key via
x.object_.keys.front, and uses x["key"] to get the payload value.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* atdd: fix D object repr for newer std.json API (ldc 1.41 / DMD 2.111)
Newer versions of std.json dropped the trailing underscore on the
JSONType.object_ enum case and JSONValue.object_ property (the underscore
was originally needed to avoid shadowing the built-in `object` module, but
the conflict was resolved in the language). Also use .keys[0] instead of
.keys.front to extract the first key of a single-element object without
needing std.range in scope.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments