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] JSON.parseArray Syntax #2535

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

[BUG] JSON.parseArray Syntax #2535

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

Comments

@Cooper-Zhong
Copy link

问题描述

{}为空json对象,JSON.parseObject正常。使用parseArray时,fastjson2抛出异常,而fastjson将其解析为[{}]

环境信息

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

重现步骤

import com.alibaba.fastjson2.JSON;
import org.junit.jupiter.api.Test;

import java.util.List;

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

public class Issue1459_54 {
    @Test
    public void testMutated() {
        String json = "{}";
        List<String> strings = JSON.parseArray(json, String.class);
        assertNotNull(strings);
    }

    @Test
    public void testMutatedfj() {
        String json = "{}";
        List<String> strings = com.alibaba.fastjson.JSON.parseArray(json, String.class);
        assertNotNull(strings);
    }
}

期待的正确结果

希望Fastjson 与Fastjson2 在解析上保持一致语法规范

相关日志输出

com.alibaba.fastjson2.JSONException: syntax error : {, offset 1, character {, line 1, column 1, fastjson-version 2.0.49 {}

at com.alibaba.fastjson2.JSONReader.readArray(JSONReader.java:2339)
at com.alibaba.fastjson2.JSON.parseArray(JSON.java:2658)
at Issue1459_54.testMutated(Issue1459_54.java:17)
@Cooper-Zhong Cooper-Zhong added the bug Something isn't working label May 7, 2024
@Cooper-Zhong
Copy link
Author

这个例子在2.0.50修复了,麻烦温少加上fixed label吧,感谢。

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

1 participant