|
|
@ -457,6 +457,10 @@ func (u *Unmarshaler) fillSlice(fieldType reflect.Type, value reflect.Value, map
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
conv.Index(i).Set(target.Elem())
|
|
|
|
conv.Index(i).Set(target.Elem())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case reflect.Slice:
|
|
|
|
|
|
|
|
if err := u.fillSlice(dereffedBaseType, conv.Index(i), ithValue); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
if err := u.fillSliceValue(conv, i, dereffedBaseKind, ithValue); err != nil {
|
|
|
|
if err := u.fillSliceValue(conv, i, dereffedBaseKind, ithValue); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -498,6 +502,17 @@ func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int, baseKind re
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
// don't need to consider the difference between int, int8, int16, int32, int64,
|
|
|
|
// don't need to consider the difference between int, int8, int16, int32, int64,
|
|
|
|
// uint, uint8, uint16, uint32, uint64, because they're handled as json.Number.
|
|
|
|
// uint, uint8, uint16, uint32, uint64, because they're handled as json.Number.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if slice.Index(index).Kind() == reflect.Ptr {
|
|
|
|
|
|
|
|
baseType := Deref(slice.Index(index).Type())
|
|
|
|
|
|
|
|
if baseType.Kind() != reflect.TypeOf(value).Kind() {
|
|
|
|
|
|
|
|
return errTypeMismatch
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
target := reflect.New(baseType).Elem()
|
|
|
|
|
|
|
|
target.Set(reflect.ValueOf(value))
|
|
|
|
|
|
|
|
slice.Index(index).Set(target.Addr())
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if slice.Index(index).Kind() != reflect.TypeOf(value).Kind() {
|
|
|
|
if slice.Index(index).Kind() != reflect.TypeOf(value).Kind() {
|
|
|
|
return errTypeMismatch
|
|
|
|
return errTypeMismatch
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -505,6 +520,7 @@ func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int, baseKind re
|
|
|
|
slice.Index(index).Set(reflect.ValueOf(value))
|
|
|
|
slice.Index(index).Set(reflect.ValueOf(value))
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue interface{}) (reflect.Value, error) {
|
|
|
|
func (u *Unmarshaler) generateMap(keyType, elemType reflect.Type, mapValue interface{}) (reflect.Value, error) {
|
|
|
|