fix: panic on convert to string on fillSliceFromString() (#1951)
* Update unmarshaler.go fix: 修复fillSliceFromString()方法中mapValue 强转string后的panic 错误 * test: 增加单元测试 增加单元测试 * Update unmarshaler_test.go
This commit is contained in:
@@ -498,8 +498,15 @@ func (u *Unmarshaler) fillSlice(fieldType reflect.Type, value reflect.Value, map
|
||||
|
||||
func (u *Unmarshaler) fillSliceFromString(fieldType reflect.Type, value reflect.Value, mapValue interface{}) error {
|
||||
var slice []interface{}
|
||||
if err := jsonx.UnmarshalFromString(mapValue.(string), &slice); err != nil {
|
||||
return err
|
||||
switch v := mapValue.(type) {
|
||||
case json.Number:
|
||||
if err := jsonx.UnmarshalFromString(v.String(), &slice); err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
if err := jsonx.UnmarshalFromString(mapValue.(string), &slice); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
baseFieldType := Deref(fieldType.Elem())
|
||||
|
||||
Reference in New Issue
Block a user