summaryrefslogtreecommitdiff
path: root/src/pkg/encoding/json/decode.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/encoding/json/decode.go')
-rw-r--r--src/pkg/encoding/json/decode.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/pkg/encoding/json/decode.go b/src/pkg/encoding/json/decode.go
index 458fb39ec..af1c908ad 100644
--- a/src/pkg/encoding/json/decode.go
+++ b/src/pkg/encoding/json/decode.go
@@ -8,6 +8,7 @@
package json
import (
+ "bytes"
"encoding"
"encoding/base64"
"errors"
@@ -15,7 +16,6 @@ import (
"reflect"
"runtime"
"strconv"
- "strings"
"unicode"
"unicode/utf16"
"unicode/utf8"
@@ -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
@@ -500,11 +505,11 @@ func (d *decodeState) object(v reflect.Value) {
d.error(errPhase)
}
- // Read string key.
+ // Read key.
start := d.off - 1
op = d.scanWhile(scanContinue)
item := d.data[start : d.off-1]
- key, ok := unquote(item)
+ key, ok := unquoteBytes(item)
if !ok {
d.error(errPhase)
}
@@ -526,11 +531,11 @@ func (d *decodeState) object(v reflect.Value) {
fields := cachedTypeFields(v.Type())
for i := range fields {
ff := &fields[i]
- if ff.name == key {
+ if bytes.Equal(ff.nameBytes, key) {
f = ff
break
}
- if f == nil && strings.EqualFold(ff.name, key) {
+ if f == nil && ff.equalFold(ff.nameBytes, key) {
f = ff
}
}
@@ -561,6 +566,7 @@ func (d *decodeState) object(v reflect.Value) {
if destring {
d.value(reflect.ValueOf(&d.tempstr))
d.literalStore([]byte(d.tempstr), subv, true)
+ d.tempstr = "" // Zero scratch space for successive values.
} else {
d.value(subv)
}