* add support for the json:",omitzero" tag
omitzero was added to the go stdlib encoder/json in go 1.24
* add case which omitempty missed: uintptr is encodable in json
and does accept omitempty in the go stdlib encoder/json.
* add omitzero test cases for pointer-to-"" and pointer-to-{}
(both should marshal to something in order to match stdlib json, and
they do)
* fix and add tests for the case when omitzero is combined with omitempty
Without a special case the generated code can look like
if v != nil && v != nil {
or
if v != "" && v != "" {
and that gets flagged by go vet (go 1.25.5)
As reported in issue #256, currently, an empty map is unmarshalled into nil by easyjson
If a field is marked "required" or "!omitempty", then the empty map is a valid input and
we should unmarshal it into an empty map.
Similar logic for marshalling.
This change is to fix the behavior
Arrays are useful to decode into to keep the allocations down
and thus the gc pressure low.
The code allows the json to contain truncated arrays without
raising an error, same as standard encoding/json. However excess
elements in the json is an error.
- nil slices are encoded as JSON nulls
- empty slices are encoded as empty JSON arrays
- byte slices are encoded as base 64 encoded JSON strings
Demo: https://play.golang.org/p/Z_YE5PHS3g