Descriptionencoding/json: properly unmarshal empty arrays.
The JSON unmarshaller failed to allocate an array when there
are no values for the input causing the `[]` unmarshalled
to []interface{} to generate []interface{}(nil) rather than
[]interface{}{}. This wasn't caught in the tests because Decode()
works correctly and because jsonBig never generated zero-sized
arrays. The modification to scanner_test.go quickly triggers
the error:
without the change to decoder.go, but with the change to scanner_test.go:
$ go test
--- FAIL: TestUnmarshalMarshal (0.10 seconds)
decode_test.go:446: Marshal jsonBig
scanner_test.go:206: diverge at 70: «03c1OL6$":null},{"[=» vs «03c1OL6$":[]},{"[=^\»
FAIL
exit status 1
FAIL encoding/json 0.266s
Also added a simple regression to decode_test.go.
Patch Set 1 #Patch Set 2 : diff -r d123462e7f18 https://go.googlecode.com/hg/ #Patch Set 3 : diff -r d123462e7f18 https://go.googlecode.com/hg/ #Patch Set 4 : diff -r d123462e7f18 https://go.googlecode.com/hg/ #Patch Set 5 : diff -r d123462e7f18 https://go.googlecode.com/hg/ #
MessagesTotal messages: 10
|