getRealDataType尅性识别优化 + Value 泛解析支持更多数据类型 #11

Merged
zhangdeman merged 2 commits from feature/bug_fix into master 2025-05-06 17:08:25 +08:00
Showing only changes of commit a0c2fb37e3 - Show all commits

View File

@ -143,7 +143,8 @@ func Any(sourceValue gjson.Result) (any, error) {
func getRealDataType(dataType consts.DataType, sourceValue gjson.Result) consts.DataType {
// 指针数据类型, 转换为普通数据类型处理
dataType = consts.DataType(strings.TrimLeft(dataType.String(), "*"))
if dataType == consts.DataTypeAny {
// 没指定数据类型或者数据类型是any
if dataType == consts.DataTypeAny || dataType == "" {
if sourceValue.IsObject() {
dataType = consts.DataTypeMapAnyAny
} else if sourceValue.IsArray() {
@ -153,6 +154,10 @@ func getRealDataType(dataType consts.DataType, sourceValue gjson.Result) consts.
} else {
if sourceValue.Type == gjson.Number {
dataType = consts.DataTypeFloat64
} else if sourceValue.Type == gjson.String {
dataType = consts.DataTypeString
} else {
dataType = consts.DataTypeAny
}
}
}