mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
json: unmarshal types that are byte slices.
The json package cheerfully would marshal
type S struct {
IP net.IP
}
but would give an error when unmarshalling. This change allows any
type whose concrete type is a byte slice to be unmarshalled from a
string.
Fixes #5086.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/11161044
This commit is contained in:
parent
09e72f5670
commit
5930649306
3 changed files with 32 additions and 3 deletions
|
|
@ -660,7 +660,7 @@ func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool
|
|||
default:
|
||||
d.saveError(&UnmarshalTypeError{"string", v.Type()})
|
||||
case reflect.Slice:
|
||||
if v.Type() != byteSliceType {
|
||||
if v.Type().Elem().Kind() != reflect.Uint8 {
|
||||
d.saveError(&UnmarshalTypeError{"string", v.Type()})
|
||||
break
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue