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

[FEATURE]fastjson2将字符串"{\"infos\": [[]], \"age\": 25}"转json时报错,但是fastjson转不报错,是否可以像fastjson一样做兼容 #1971

Closed
bf109f opened this issue Oct 31, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request fixed
Milestone

Comments

@bf109f
Copy link

bf109f commented Oct 31, 2023

请描述您的需求或者改进建议

对您想要需求或建议的清晰简洁的描述。
测试代码如下:
String str = "{\"infos\": [[]], \"age\": 25}"; Test testb = JSON.parseObject(str, Test.class); System.out.println(testb.getInfos()); Test testa = com.alibaba.fastjson2.JSON.parseObject(str, Test.class);
第一行打印
[null]
第二行报错
Exception in thread "main" com.alibaba.fastjson2.JSONException: expect {, but [, class utils.Info, parent fieldName infos, offset 12, character [, line 1, column 13, fastjson-version 2.0.41 {"infos": [[]], "age": 25}

测试类
`
public class Test {

private List<Info> infos;

private int age;

public List<Info> getInfos() {
    return infos;
}

public void setInfos(List<Info> infos) {
    this.infos = infos;
}

public int getAge() {
    return age;
}

public void setAge(int age) {
    this.age = age;
}

}

public class Info {
private List name;

public List<String> getName() {
    return name;
}

public void setName(List<String> name) {
    this.name = name;
}

}
`

请描述你建议的实现方案

对您想要需求或建议的实现方案的详细描述。

描述您考虑过的替代方案

对您考虑过的任何替代解决方案或功能的描述。

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

@bf109f bf109f added the enhancement New feature or request label Oct 31, 2023
@yanxutao89 yanxutao89 self-assigned this Oct 31, 2023
yanxutao89 added a commit to yanxutao89/fastjson2 that referenced this issue Oct 31, 2023
wenshao pushed a commit that referenced this issue Oct 31, 2023
@wenshao wenshao added this to the 2.0.42 milestone Nov 2, 2023
@wenshao wenshao added the fixed label Nov 2, 2023
@wenshao
Copy link
Member

wenshao commented Nov 5, 2023

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

@wenshao wenshao closed this as completed Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed
Projects
None yet
Development

No branches or pull requests

3 participants