mirror of
https://github.com/golang/go
synced 2024-11-14 20:10:30 -07:00
encoding/json: clarify omitempty option for {array,slice,map,string}
This CL is inspired by:
https://github.com/golang/go/issues/29310#issuecomment-758768325
When I read omitempty option in encoding/xml package, I find it's
a bit different than encoding/json package.
I think it's more precise to say:
"any array, slice, map, or string of length zero."
Update #29310
Change-Id: Ia77167c3155411640224b349d4b34d0bb91ee11e
GitHub-Last-Rev: a4cf00dcc7
GitHub-Pull-Request: golang/go#69984
Reviewed-on: https://go-review.googlesource.com/c/go/+/621835
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
3cb0c039e9
commit
9f26d35fac
@ -72,8 +72,8 @@ import (
|
||||
//
|
||||
// The "omitempty" option specifies that the field should be omitted
|
||||
// from the encoding if the field has an empty value, defined as
|
||||
// false, 0, a nil pointer, a nil interface value, and any empty array,
|
||||
// slice, map, or string.
|
||||
// false, 0, a nil pointer, a nil interface value, and any array,
|
||||
// slice, map, or string of length zero.
|
||||
//
|
||||
// As a special case, if the field tag is "-", the field is always omitted.
|
||||
// Note that a field with name "-" can still be generated using the tag "-,".
|
||||
|
Loading…
Reference in New Issue
Block a user