增加对[]interface的处理

This commit is contained in:
zhangdeman committed 2023-05-04 18:18:03 +08:00
1 parent 6130732a90
commit 920b2c45b9
1 file changed
+13 -1
+13 -1
View File
@@ -176,7 +176,10 @@ func (f *filter) Parse(receiver interface{}) error {
func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValue string) (interface{}, error) {
sourceValueStr := defaultValue
if sourceValue.Exists() {
sourceValueStr = sourceValue.String()
str := sourceValue.String()
if len(str) > 0 {
sourceValueStr = str
}
}
switch dataType {
@@ -236,6 +239,15 @@ func (f *filter) getValue(dataType string, sourceValue gjson.Result, defaultValu
return sourceValueStr, nil
case DataTypeAny:
return sourceValue.Value(), nil
case DataTypeAnySlice:
// 任意类型的list
var (
result []interface{}
)
if err := util.JSON.UnmarshalWithNumber([]byte(sourceValueStr), &result); nil != err {
return nil, err
}
return result, nil
default:
return nil, errors.New(dataType + " is not support!")
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.