Skip to content
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

Closed
non-native opened this issue Aug 26, 2022 · 4 comments
Labels
bug Something isn't working fixed question Further information is requested
Milestone

Comments

@non-native
Copy link

JSON.parse

在fastjson1中,使用 JSON.parse("123a") 会抛出异常 om.alibaba.fastjson.JSONException: not close json text, token : error。
但是在fastjson2中,会直接输出:123,且并未抛出异常。

请问这种情况如何处理?如果JSON.parse不抛出异常,也应该输出全部的字符串吧?但如果字符串以数字开头则只截取了的数字进行输出,这是为什么呢?

@non-native non-native added the question Further information is requested label Aug 26, 2022
@non-native
Copy link
Author

image
image

@wenshao wenshao added the bug Something isn't working label Aug 26, 2022
@wenshao wenshao added this to the 2.0.13 milestone Aug 26, 2022
wenshao added a commit that referenced this issue Aug 26, 2022
@wenshao
Copy link
Member

wenshao commented Aug 26, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.13-SNAPSHOT/
问题已经修复,请用2.0.13-SNAPSHOT版本验证,2.0.13版本预计在9月12日前发布

@wenshao wenshao added the fixed label Aug 26, 2022
@wenshao
Copy link
Member

wenshao commented Sep 10, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.13
2.0.13版本已经发布,请用帮忙用新版本验证

@wenshao wenshao closed this as completed Sep 10, 2022
@lunfangyu
Copy link

https://github.com/alibaba/fastjson2/releases/tag/2.0.13 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
Labels
bug Something isn't working fixed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants