aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2024-12-27 17:24:30 -0800
committerJoseph Tsai <joetsai@digital-static.net>2024-12-30 12:21:48 -0800
commit15f232456a8741c84ee0bd38dce28978eab6a491 (patch)
tree91a371f5692c5acc1b6b09ec845b9c6adb3f9c7b /src/encoding
parentba1deb1ceef956bdb3ca5a9570f132cf19ccc9f6 (diff)
downloadgo-15f232456a8741c84ee0bd38dce28978eab6a491.tar.xz
encoding/json: remove suggestion on Unmarshaler with JSON null
It is not true that Unmarshal always treats a JSON null as being equivalent to a no-op. For bools, ints, uints, floats, strings, arrays, and structs, it treats a JSON null as a no-op. However, for []byte, slice, map, pointer, or interface, it zeros the underlying value. Remove this suggestion as the actual behavior is inconsistent. Note that the proposed behavior in v2 Unmarshal is to consistently zero out the underlying value. Change-Id: I02cef0bf7919f25cfd0aceb04486d37498761181 Reviewed-on: https://go-review.googlesource.com/c/go/+/638416 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Diffstat (limited to 'src/encoding')
-rw-r--r--src/encoding/json/decode.go3
1 files changed, 0 insertions, 3 deletions
diff --git a/src/encoding/json/decode.go b/src/encoding/json/decode.go
index 98102291ab..3b398c9fc3 100644
--- a/src/encoding/json/decode.go
+++ b/src/encoding/json/decode.go
@@ -113,9 +113,6 @@ func Unmarshal(data []byte, v any) error {
// The input can be assumed to be a valid encoding of
// a JSON value. UnmarshalJSON must copy the JSON data
// if it wishes to retain the data after returning.
-//
-// By convention, to approximate the behavior of [Unmarshal] itself,
-// Unmarshalers implement UnmarshalJSON([]byte("null")) as a no-op.
type Unmarshaler interface {
UnmarshalJSON([]byte) error
}