From 911ff18b5a0a44b1963699d04798e5cd3ff08976 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, 9 Nov 2021 22:01:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E8=A7=A3?= =?UTF-8?q?=E6=9E=90,=E6=94=AF=E6=8C=81float64=E5=90=91=E4=B8=8B=E5=85=BC?= =?UTF-8?q?=E5=AE=B9int64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tool/json2go/parser.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tool/json2go/parser.go b/tool/json2go/parser.go index 61918d5..0576fc2 100644 --- a/tool/json2go/parser.go +++ b/tool/json2go/parser.go @@ -80,7 +80,12 @@ func (jg *JSON2GO) parseArray(key string, parseResult gjson.Result) { dataType = jg.getDataType(item) continue } - if jg.getDataType(item) != dataType { + currentType := jg.getDataType(item) + if currentType != dataType { + if (dataType == "int64" && currentType == "float64") || (dataType == "float64" && currentType == "int64") { + dataType = "float64" + continue + } // 不是所有数据类型都一致 if len(key) == 0 { jg.result += "interface{}"