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

JSON校验问题[BUG] #410

Closed
wycst opened this issue Jun 5, 2022 · 3 comments
Closed

JSON校验问题[BUG] #410

wycst opened this issue Jun 5, 2022 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@wycst
Copy link

wycst commented Jun 5, 2022

   错误的json也能解析,isValid返回的也是true,下面是代码:

    String json = "{\"key1\":11444-sdsdsd\"key2\":\"sdsdssdsda\"}";
    boolean validate = com.alibaba.fastjson2.JSON.isValid(json);
    System.out.println(" validate: " + validate);
    JSONObject value = com.alibaba.fastjson2.JSON.parseObject(json);
    System.out.println(value);
@wycst wycst added the bug Something isn't working label Jun 5, 2022
@wenshao wenshao added this to the 2.0.7 milestone Jun 5, 2022
wenshao added a commit that referenced this issue Jun 5, 2022
@wenshao
Copy link
Member

wenshao commented Jun 6, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.7-SNAPSHOT/

问题已经修复,你可以先用2.0.7-SNAPSHOT版本验证

@wycst
Copy link
Author

wycst commented Jun 7, 2022

问题还是存在。

String json = "{\n" +
" "store": {\n" +
" "book": [\n" +
" {\n" +
" "category": "reference",\n" +
" "author": "Nigel Rees"\n" + // 这行把逗号去掉了
" "title": "Sayings of the Century",\n" +
" "price": 8.95\n1-" + // 这行在回车后面加了多余字符
" },\n" +
" {\n" +
" "category": "fiction",\n" +
" "author": "Evelyn Waugh",\n" +
" "title": "Sword of Honour",\n" +
" "price": 12.99\n" +
" },\n" +
" {\n" +
" "category": "fiction",\n" +
" "author": "Herman Melville",\n" +
" "title": "Moby Dick",\n" +
" "isbn": "0-553-21311-3",\n" +
" "price": 8.99\n" +
" },\n" +
" {\n" +
" "category": "fiction",\n" +
" "author": "J. R. R. Tolkien",\n" +
" "title": "The Lord of the Rings",\n" +
" "isbn": "0-395-19395-8",\n" +
" "price": 22.99\n" +
" }\n" +
" ],\n" +
" "bicycle": {\n" +
" "color": "red",\n" +
" "price": 19.95\n" +
" }\n" +
" },\n" +
" "expensive": 10\n" +
"}\n";
System.out.println(JSON.isValid(json));
System.out.println(JSON.parse(json));

@wycst wycst closed this as completed Jun 10, 2022
@wenshao
Copy link
Member

wenshao commented Jun 11, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.7
问题已经修复,请用新版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants