Sample
Show that `omitzero` now changes omission semantics from zero-value checks to `IsZero()`-based suppression.
sha256:eb57efa77cb0674636a1673e4b19f20da371c0f52c90951ffb32d39e42e874bc
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Case
- Goal
- Show that `omitzero` now changes omission semantics from zero-value checks to `IsZero()`-based suppression. HOW
- Packages
- encoding/json go1.26.5
- Environment
- go
- Created
- 2026-08-16T13:04:28Z
Commonly assumed
A field is omitted only when its value is reflect-empty, so a non-empty struct value must always be serialized unless `omitempty` is false.
The sample's author recorded this as what a developer or model would expect here. The contract below is what actually ran.
Contract
- assert json.Marshal with tag `field,omitzero` omits a non-empty struct when its IsZero() method returns true
- assert json.Marshal with tag `field,omitempty` keeps that same non-empty struct value
Files
- NOTES.md
- csx.json
- go.mod
- json_v2_strict_test.go
Download the verified artifact (tar.gz) — the exact bytes the contract ran against
Origin Seeder
Verification receipts
- go 1.26 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-16 · ed25519:d91480838ac982c9