alibaba / fastjson2

🚄 FASTJSON2 is a Java JSON library with excellent performance.
Apache License 2.0
3.78k stars 495 forks source link

[BUG] 千分符表示的字符串转long失败 #2461

Closed wenl001 closed 6 months ago

wenl001 commented 6 months ago

问题描述

科学计数法字符串转long失败,fastjson可以

环境信息

请填写以下信息:

重现步骤

如何操作可以重现该问题:

1、字符串: String channelRespBody="{\"openTime\":\"1,659,597,865\",\"startTime\":1712903332573 }"; 2、待转类型: private Long openTime;

期待的正确结果

openTime = 1,659597865

相关日志输出

请复制并粘贴任何相关的日志输出。 Exception in thread "main" com.alibaba.fastjson2.JSONException: parseLong error, value : 1,659,597,865 at com.alibaba.fastjson2.JSONReader.toInt64(JSONReader.java:3133) at com.alibaba.fastjson2.JSONReader.getInt64(JSONReader.java:984) at com.alibaba.fastjson2.JSONReaderUTF16.readInt64(JSONReaderUTF16.java:3144) at com.alibaba.fastjson2.reader.ORG_1_22_EeCheckIbanBo.readObject(Unknown Source) at com.alibaba.fastjson2.JSON.parseObject(JSON.java:726) at com.kucoin.wallet.chaincommon.pay.test.TestFastjson.main(TestFastjson.java:52)

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

wenshao commented 6 months ago

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.50-SNAPSHOT/ 问题已修复,请帮忙用2.0.50-SNAPSHOT版本验证

wenshao commented 6 months ago

https://github.com/alibaba/fastjson2/releases/tag/2.0.50 2.0.50已发布,请用新版本

wu979 commented 4 weeks ago

{"content":"jonathan.yue Apply to join the organization","extra":{"relationId":200,000,000,002,005,"orgId":"rxDDjvGQmUyYrPom","subType":"JOIN_APPLY"},"push":{"content":"jonathan.yue Apply to join the organization","params":{"relationId":200,000,000,002,005,"orgId":"rxDDjvGQmUyYrPom","subType":"JOIN_APPLY"},"subject":"Organizational Reminder","type":"ORG_MEM"},"subject":"Organizational Reminder","type":"ORG_MEM"}

2.0.9 由于科学计数法的原因,升级到了2.0.50,报了新的错误 syntax error, illegal key-value, offset 88, character 0, line 1, column 88, fastjson-version 2.0.53 {"content":"jonathan.yue Apply to join the organization","extra":{"relationId":200,000,000,002,005,"orgId":"rxDDjvGQmUyYrPom","subType":"JOIN_APPLY"},"push":{"content":"jonathan.yue Apply to join the organization","params":{"relationId":200,000,000,002,005,"orgId":"rxDDjvGQmUyYrPom","subType":"JOIN_APPLY"},"subject":"Organizational Reminder","type":"ORG_MEM"},"subject":"Organizational Reminder","type":"ORG_MEM"} 升级到2.0.53还是同样的问题

@wenshao