json: fix array -> non-array decoding

Fixes #773.

R=adg
CC=golang-dev
https://golang.org/cl/1120042
This commit is contained in:
Russ Cox 2010-05-11 14:38:55 -07:00
parent 916426ea76
commit 4e5bc6a8fe
2 changed files with 30 additions and 19 deletions

View file

@ -304,6 +304,9 @@ func (d *decodeState) array(v reflect.Value) {
av, ok := v.(reflect.ArrayOrSliceValue)
if !ok {
d.saveError(&UnmarshalTypeError{"array", v.Type()})
d.off--
d.next()
return
}
sv, _ := v.(*reflect.SliceValue)