User struct { ID int `json:"id"` // reads and write to 'id' key Name string `json:"name,omitempty"` // omitted when null Address string `json:"address,omitzero"` // omitted when value is 'zero' BirthDay time.Time `json:"-"` // ignored both in Marshal and Unmarshal }
v2 export GOEXPERIMENT=jsonv2 # Or for specific commands GOEXPERIMENT=jsonv2 go run main.go Code Changes Required // v1 (still works with v2 enabled) import "encoding/json" // v2 (new package) import "encoding/json/v2"
faster unmarshaling Memory Usage Buffers all data True streaming Formatting Limited options Full control via Options and tags Default Behavior Nil → null Nil → empty values Production Ready Stable Experimental
2. True streaming is now possible 3. Breaking changes require careful migration planning 4. Experimental status means wait for production use 5. Future-focused - prepare for eventual migration