diff options
| author | Russ Cox <rsc@golang.org> | 2014-05-12 23:38:26 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2014-05-12 23:38:26 -0400 |
| commit | fc1e5a8acdfba04482bb17b4ad5bbd3778c50fb3 (patch) | |
| tree | fe6c15f5edc4d90013f1093ee8b9cf73f2eb0e93 /src/pkg/encoding | |
| parent | 92440fb5bd43912e363f32409bba5d6880356d60 (diff) | |
| download | go-fc1e5a8acdfba04482bb17b4ad5bbd3778c50fb3.tar.xz | |
encoding/json: document what unmarshal of `null` into non-reference type does
Originally it was an error, which made perfect sense, but in issue 2540
I got talked out of this sensible behavior. I'm not thrilled with the "new"
behavior but it's been there since Go 1.1 so we're stuck with it now.
Fixes #6724.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/100430043
Diffstat (limited to 'src/pkg/encoding')
| -rw-r--r-- | src/pkg/encoding/json/decode.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/pkg/encoding/json/decode.go b/src/pkg/encoding/json/decode.go index dde0d78e32..af1c908ad7 100644 --- a/src/pkg/encoding/json/decode.go +++ b/src/pkg/encoding/json/decode.go @@ -54,6 +54,11 @@ import ( // If no more serious errors are encountered, Unmarshal returns // an UnmarshalTypeError describing the earliest such error. // +// The JSON null value unmarshals into an interface, map, pointer, or slice +// by setting that Go value to nil. Because null is often used in JSON to mean +// ``not present,'' unmarshaling a JSON null into any other Go type has no effect +// on the value and produces no error. +// // When unmarshaling quoted strings, invalid UTF-8 or // invalid UTF-16 surrogate pairs are not treated as an error. // Instead, they are replaced by the Unicode replacement |
