数据类型解析,支持float64向下兼容int64
This commit is contained in:
parent
d491d147f4
commit
911ff18b5a
@ -80,7 +80,12 @@ func (jg *JSON2GO) parseArray(key string, parseResult gjson.Result) {
|
|||||||
dataType = jg.getDataType(item)
|
dataType = jg.getDataType(item)
|
||||||
continue
|
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 {
|
if len(key) == 0 {
|
||||||
jg.result += "interface{}"
|
jg.result += "interface{}"
|
||||||
|
Loading…
Reference in New Issue
Block a user