优化自动生成json #3

Merged
zhangdeman merged 24 commits from feature/tree into master 2023-05-05 16:10:39 +08:00
Showing only changes of commit 920b2c45b9 - Show all commits

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!")
}