diff --git a/filter.go b/filter.go index 426cad0..61d1b0c 100644 --- a/filter.go +++ b/filter.go @@ -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!") }