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

List<List<Object>> 类型数据parseObject时报错 #1312

Closed
jasonwagz opened this issue Apr 3, 2023 · 2 comments
Closed

List<List<Object>> 类型数据parseObject时报错 #1312

jasonwagz opened this issue Apr 3, 2023 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@jasonwagz
Copy link

jasonwagz commented Apr 3, 2023

问题描述

List<List> 类型数据parseObject时报错

环境信息

  • JDK信息: [e.g.:Openjdk 1.8.0_312]
  • 版本信息:[e.g.:Fastjson2 2.0.26]

重现步骤

import java.util.List;

public class Test {

public static void main(String[] args) {
    String s = "{\"values\":[[123,456]]}";

    Data data1 = com.alibaba.fastjson.JSON.parseObject(s, Data.class);
    System.out.println("fastjson data:" + com.alibaba.fastjson.JSON.toJSONString(data1));

    Data data2 = com.alibaba.fastjson2.JSON.parseObject(s, Data.class);
    System.out.println("fastjson2 data:" + com.alibaba.fastjson2.JSON.toJSONString(data2));
}

public static class Data {

    private List<List<Object>> values;

    public List<List<Object>> getValues() {
        return values;
    }

    public void setValues(List<List<Object>> values) {
        this.values = values;
    }
}

}

期待的正确结果

内层List中数据类型不定,期望能正常解析

相关日志输出

fastjson data:{"values":[[123,456]]}
Exception in thread "main" com.alibaba.fastjson2.JSONException: offset 13, character 1, line 1, column 14, fastjson-version 2.0.26 {"values":[[123,456]]}
at com.alibaba.fastjson2.reader.ObjectReaderImplList.readObject(ObjectReaderImplList.java:503)
at com.alibaba.fastjson2.reader.ObjectReaderImplList.readObject(ObjectReaderImplList.java:536)
at com.alibaba.fastjson2.reader.ORG_1_1_Data.readObject(Unknown Source)
at com.alibaba.fastjson2.JSON.parseObject(JSON.java:642)
at Test.main(Test.java:13)

@jasonwagz jasonwagz added the bug Something isn't working label Apr 3, 2023
@wenshao wenshao added this to the 2.0.27 milestone Apr 4, 2023
@wenshao wenshao added the fixed label Apr 4, 2023
@wenshao
Copy link
Member

wenshao commented Apr 4, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.27-SNAPSHOT/
问题已修复,请帮忙用2.0.27-SNAPSHOT版本验证

@wenshao
Copy link
Member

wenshao commented Apr 8, 2023

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

@wenshao wenshao closed this as completed Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants