优化自动生成json #3

Merged
zhangdeman merged 24 commits from feature/tree into master 2023-05-05 16:10:39 +08:00
920b2c45b9 增加对[]interface的处理
白茶清欢
2023-05-04 18:18:03 +08:00
Commit 20 of 24
Show all commits
+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.