From a0c2fb37e3f80307d564c523e9ccf746fe1143b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 6 May 2025 17:07:45 +0800 Subject: [PATCH] =?UTF-8?q?getRealType=E9=80=82=E9=85=8D=E6=9C=AA=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gjson_hack/precision.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gjson_hack/precision.go b/gjson_hack/precision.go index 9d1d8f5..d2c3461 100644 --- a/gjson_hack/precision.go +++ b/gjson_hack/precision.go @@ -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 } } }