mirror of
https://github.com/golang/go.git
synced 2025-11-08 12:41:02 +00:00
encoding/json: fix decoding of types with '[]byte' as underlying type
All slice types which have elements of kind reflect.Uint8 are marshalled into base64 for compactness. When decoding such data into a custom type based on []byte the decoder checked the slice kind instead of the slice element kind, so no appropriate decoder was found. Fixed by letting the decoder check slice element kind like the encoder. This guarantees that already encoded data can still be successfully decoded. Fixes #8962. Change-Id: Ia320d4dc2c6e9e5fe6d8dc15788c81da23d20c4f Reviewed-on: https://go-review.googlesource.com/9371 Reviewed-by: Peter Waldschmidt <peter@waldschmidt.com> Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
5726af54eb
commit
4302fd0409
3 changed files with 22 additions and 3 deletions
|
|
@ -275,8 +275,6 @@ func (e *encodeState) error(err error) {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
var byteSliceType = reflect.TypeOf([]byte(nil))
|
||||
|
||||
func isEmptyValue(v reflect.Value) bool {
|
||||
switch v.Kind() {
|
||||
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue