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

[BUG] JSONObject.parse不正确 #2522

Open
Cooper-Zhong opened this issue May 6, 2024 · 1 comment
Open

[BUG] JSONObject.parse不正确 #2522

Cooper-Zhong opened this issue May 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Cooper-Zhong
Copy link

问题描述

Fastjson中JSONObject.parse 与Fastjson2有差异

环境信息

  • OS信息: [MacOS 12.7.4 M1 Pro 16 GB]
  • JDK信息: [Openjdk 17.0.6]
  • 版本信息:[Fastjson 2.0.49]

重现步骤

import com.alibaba.fastjson2.JSONException;
import com.alibaba.fastjson2.JSONObject;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertThrows;

public class Issue2155Mutated_241 {
    @Test
    public void test() {
        assertThrows(
                JSONException.class,
                () -> JSONObject.parse("{[1,2]}"));
    }

    @Test
    public void test1() {
        assertThrows(
                com.alibaba.fastjson.JSONException.class,
                () -> com.alibaba.fastjson.JSONObject.parse("{[1,2]}"));
    }

}

期待的正确结果

{[1,2]} is an invalid json on https://jsonlint.com/
fastjson does not throw any exception

相关日志输出

Expected com.alibaba.fastjson.JSONException to be thrown, but nothing was thrown.

@Cooper-Zhong Cooper-Zhong added the bug Something isn't working label May 6, 2024
@wenshao wenshao modified the milestones: 2.0.50, 2.0.51 May 7, 2024
@wenshao wenshao removed this from the 2.0.51 milestone May 22, 2024
@wenshao
Copy link
Member

wenshao commented May 22, 2024

这个兼容API处理异常json的错误优先级不高,晚些时间再处理哈

wenshao added a commit that referenced this issue May 22, 2024
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