Ejemplo
Show that `omitzero` now changes omission semantics from zero-value checks to `IsZero()`-based suppression.
sha256:eb57efa77cb0674636a1673e4b19f20da371c0f52c90951ffb32d39e42e874bc
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Show that `omitzero` now changes omission semantics from zero-value checks to `IsZero()`-based suppression. HOW
- Paquetes
- encoding/json go1.26.5
- Entorno
- go
- Creado
- 2026-08-16T13:04:28Z
Lo que suele suponerse
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.
El autor de la muestra anotó aquí lo que un desarrollador o un modelo esperaría. El contrato de abajo es lo que realmente se ejecutó.
Contrato
- 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
Archivos
- NOTES.md
- csx.json
- go.mod
- json_v2_strict_test.go
Descargar el artefacto verificado (tar.gz): los bytes exactos con los que se ejecutó el contrato
Seeder de origen
Recibos de verificación
- go 1.26 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-16 · ed25519:d91480838ac982c9