aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/decode.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-07-14 21:32:47 -0400
committerRuss Cox <rsc@golang.org>2015-07-15 05:51:02 +0000
commit749b391c55b0139910d86ac0f8a0c42957e01d1c (patch)
tree45da770d6adc365254497daa935cf93381419a9c /src/encoding/json/decode.go
parent2d25318f086fd7583c261f3b440a85dced2b63b4 (diff)
downloadgo-749b391c55b0139910d86ac0f8a0c42957e01d1c.tar.xz
encoding/json: document and test overwrite of slice, map during Unmarshal
Fixes #8837. Change-Id: Iaaecbb0b324004cb74b16b764126b01315e6a16e Reviewed-on: https://go-review.googlesource.com/12209 Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src/encoding/json/decode.go')
-rw-r--r--src/encoding/json/decode.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/encoding/json/decode.go b/src/encoding/json/decode.go
index 02deac4c9f..530e8521dc 100644
--- a/src/encoding/json/decode.go
+++ b/src/encoding/json/decode.go
@@ -48,6 +48,13 @@ import (
// map[string]interface{}, for JSON objects
// nil for JSON null
//
+// To unmarshal a JSON array into a slice, Unmarshal resets the slice to nil
+// and then appends each element to the slice.
+//
+// To unmarshal a JSON object into a map, Unmarshal replaces the map
+// with an empty map and then adds key-value pairs from the object to
+// the map.
+//
// If a JSON value is not appropriate for a given target type,
// or if a JSON number overflows the target type, Unmarshal
// skips that field and completes the unmarshalling as best it can.