|
|
@ -207,6 +207,8 @@ func (u *Unmarshaler) processFieldNotFromString(field reflect.StructField, value
|
|
|
|
return u.fillMap(field, value, mapValue)
|
|
|
|
return u.fillMap(field, value, mapValue)
|
|
|
|
case valueKind == reflect.String && typeKind == reflect.Slice:
|
|
|
|
case valueKind == reflect.String && typeKind == reflect.Slice:
|
|
|
|
return u.fillSliceFromString(fieldType, value, mapValue)
|
|
|
|
return u.fillSliceFromString(fieldType, value, mapValue)
|
|
|
|
|
|
|
|
case valueKind == reflect.String && typeKind == reflect.Map:
|
|
|
|
|
|
|
|
return u.fillMapFromString(value, mapValue)
|
|
|
|
case valueKind == reflect.String && derefedFieldType == durationType:
|
|
|
|
case valueKind == reflect.String && derefedFieldType == durationType:
|
|
|
|
return fillDurationValue(fieldType.Kind(), value, mapValue.(string))
|
|
|
|
return fillDurationValue(fieldType.Kind(), value, mapValue.(string))
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -530,6 +532,23 @@ func (u *Unmarshaler) fillSliceFromString(fieldType reflect.Type, value reflect.
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (u *Unmarshaler) fillMapFromString(value reflect.Value, mapValue interface{}) error {
|
|
|
|
|
|
|
|
switch v := mapValue.(type) {
|
|
|
|
|
|
|
|
case fmt.Stringer:
|
|
|
|
|
|
|
|
if err := jsonx.UnmarshalFromString(v.String(), value.Addr().Interface()); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
case string:
|
|
|
|
|
|
|
|
if err := jsonx.UnmarshalFromString(v, value.Addr().Interface()); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return errUnsupportedType
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int,
|
|
|
|
func (u *Unmarshaler) fillSliceValue(slice reflect.Value, index int,
|
|
|
|
baseKind reflect.Kind, value interface{}) error {
|
|
|
|
baseKind reflect.Kind, value interface{}) error {
|
|
|
|
ithVal := slice.Index(index)
|
|
|
|
ithVal := slice.Index(index)
|
|
|
|