Skip to content

Commit 9f26d35

Browse files
callthingsoffgopherbot
authored andcommitted
encoding/json: clarify omitempty option for {array,slice,map,string}
This CL is inspired by: #29310 (comment) 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: a4cf00d GitHub-Pull-Request: #69984 Reviewed-on: https://go-review.googlesource.com/c/go/+/621835 Auto-Submit: Ian Lance Taylor <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Joseph Tsai <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent 3cb0c03 commit 9f26d35

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/encoding/json/encode.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ import (
7272
//
7373
// The "omitempty" option specifies that the field should be omitted
7474
// from the encoding if the field has an empty value, defined as
75-
// false, 0, a nil pointer, a nil interface value, and any empty array,
76-
// slice, map, or string.
75+
// false, 0, a nil pointer, a nil interface value, and any array,
76+
// slice, map, or string of length zero.
7777
//
7878
// As a special case, if the field tag is "-", the field is always omitted.
7979
// Note that a field with name "-" can still be generated using the tag "-,".

0 commit comments

Comments
 (0)