@@ -48,12 +48,22 @@ import (
48
48
// map[string]interface{}, for JSON objects
49
49
// nil for JSON null
50
50
//
51
- // To unmarshal a JSON array into a slice, Unmarshal resets the slice to nil
52
- // and then appends each element to the slice.
51
+ // To unmarshal a JSON array into a slice, Unmarshal resets the slice length
52
+ // to zero and then appends each element to the slice.
53
+ // As a special case, to unmarshal an empty JSON array into a slice,
54
+ // Unmarshal replaces the slice with a new empty slice.
53
55
//
54
- // To unmarshal a JSON object into a map, Unmarshal replaces the map
55
- // with an empty map and then adds key-value pairs from the object to
56
- // the map.
56
+ // To unmarshal a JSON array into a Go array, Unmarshal decodes
57
+ // JSON array elements into corresponding Go array elements.
58
+ // If the Go array is smaller than the JSON array,
59
+ // the additional JSON array elements are discarded.
60
+ // If the JSON array is smaller than the Go array,
61
+ // the additional Go array elements are set to zero values.
62
+ //
63
+ // To unmarshal a JSON object into a string-keyed map, Unmarshal first
64
+ // establishes a map to use, If the map is nil, Unmarshal allocates a new map.
65
+ // Otherwise Unmarshal reuses the existing map, keeping existing entries.
66
+ // Unmarshal then stores key-value pairs from the JSON object into the map.
57
67
//
58
68
// If a JSON value is not appropriate for a given target type,
59
69
// or if a JSON number overflows the target type, Unmarshal
0 commit comments