当前位置: 首页 > 知识库问答 >
问题:

firebase.database.databaseException:反序列化时需要一个映射,但得到了一个类java.util.ArrayList

段干长恨
2023-03-14
public class Category {
    private String link;
    private String categoryName;
    private String activeJob;
    private Map<String, JobList> jobList;

    ....

    public Map<String, JobList> getJobList() {
        return jobList;
    }

    public void setJobList(Map<String, JobList> jobList) {
        this.jobList = jobList;
    }
}
public class JobList {
    private String employerName;
    private String jobClosingDate;
    private String jobCode;
    private String jobTitle;
    private String jobLink;
    private String status;
    private String updatedDate;

在MainActivity

public void getJobListFromFirebase() {
        ChildEventListener childEventListener = new ChildEventListener() {
            @Override
            public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

                categories = dataSnapshot.getValue(Category.class);
            }
            @Override
            public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

            }
            .......

共有1个答案

周飞语
2023-03-14
    private String link;
    private String categoryName;
    private String activeJob;
    private List<JobList> jobList;

    ....

    public List<JobList> getJobList() {
        return jobList;
    }

    public void setJobList(List<JobList> jobList) {
        this.jobList = jobList;
    }
}
 类似资料: