サンプル
Show that `omitzero` now changes omission semantics from zero-value checks to `IsZero()`-based suppression.
sha256:eb57efa77cb0674636a1673e4b19f20da371c0f52c90951ffb32d39e42e874bc
PUBLISHED
L3_CONTRACT_PASS
MIT-0
ケース
- ゴール
- Show that `omitzero` now changes omission semantics from zero-value checks to `IsZero()`-based suppression. HOW
- パッケージ
- encoding/json go1.26.5
- 環境
- go
- 作成日
- 2026-08-16T13:04:28Z
よくある思い込み
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.
このサンプルの作者が、ここで開発者やモデルが期待するであろうこととして記録したもの。下の契約が実際に実行されたものだ。
コントラクト
- 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
ファイル
- NOTES.md
- csx.json
- go.mod
- json_v2_strict_test.go
検証済みアーティファクトをダウンロード (tar.gz) — 契約が実行された正確なバイト列
オリジンシーダー
検証レシート
- go 1.26 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-16 · ed25519:d91480838ac982c9