Skip to content

希望支持链式嵌套json数组解析为List<T> #64

Description

@dododcdc

比如我的数据类型是这样的:

{"data":[
{
    "created_at":"Sat May 14 22:05:52 +0800 2022",
    "id": "4769148843065803",
    "disable_reply": 0,
    "comments":[
        {
            "created_at":"Sat May 14 22:09:52 +0800 2022",
            "id": "4769148843065805",
            "disable_reply": 1,
            "comments":[]
        },
        {
            "created_at":"Sat May 14 22:20:52 +0800 2022",
            "id": "4769148843065807",
            "disable_reply": 4,
            "comments":[]
        }
    ]
},
{
"省略":"省略"
}
]
}

我尝试建一个映射类去接收:

import java.util.List;
@Data
public class Comment {
    //评论时间
    private String created_at;
   // 省略部分字段.......
    // 该条评论下的评论
    private List<Comment> comments;
}

我的接收处理:

List<Comment> cts= data.getArray("data").toList(Comment.class);

目前无法接收,会报如下错误:
image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions