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 on illegal string with extra '{' #2738

Open
Cooper-Zhong opened this issue Jun 25, 2024 · 0 comments
Open

[BUG] JSON.parseArray on illegal string with extra '{' #2738

Cooper-Zhong opened this issue Jun 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Cooper-Zhong
Copy link
Contributor

问题描述

#235, 字符串多了一个 '}',fastjson兼容JSON.parseArray未报错

环境信息

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

重现步骤

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class Issue235 {

    @Test
    public void testOriginalJsonParsing() {
        String json = "[{\r\n"
                      + "  \"namespace\":\"unit07\", \r\n"
                      + "  \"items\":[\"COUNTER13_14.AV\",\r\n"
                      + "  \"COUNTER13_15.AV\"]\r\n"
                      + "}\r\n"
                      + "}]";

        assertThrows(JSONException.class, () -> JSON.parseArray(json, TModal.class));
    }


    public static class TModal {
        private String namespace;
        private List<String> items;

    }
}

期待的正确结果

Maybe should throw an 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 Jun 25, 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

1 participant