-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fastjson2 JSON.parse 在解析字符串时,遇到非JSON字符不报错[QUESTION] #711
Comments
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.13-SNAPSHOT/ |
https://github.com/alibaba/fastjson2/releases/tag/2.0.13 |
验证发现:JSON.parse("123a")会抛异常,但是JSON.parse("123")则不抛异常。为什么这么处理呢?怎么判断一个字符串是否为JSON ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JSON.parse
在fastjson1中,使用 JSON.parse("123a") 会抛出异常 om.alibaba.fastjson.JSONException: not close json text, token : error。
但是在fastjson2中,会直接输出:123,且并未抛出异常。
请问这种情况如何处理?如果JSON.parse不抛出异常,也应该输出全部的字符串吧?但如果字符串以数字开头则只截取了的数字进行输出,这是为什么呢?
The text was updated successfully, but these errors were encountered: