我无法使用Fasterxml / jackson将以下JSON数据转换为JAVA POJO
{
"listofMeetings": {
"0034B00000X2zPmQAJ": {
"to_do_order": 1,
"to_do_action_type": "Scheduled Meet/Call",
"to_do_action_type_id": "TD1",
"userId": "290bd895fbc98e35cdc0"
},
"0034B00000X2iqBQAR": {
"to_do_order": 2,
"to_do_action_type": "Routine Follow Up",
"to_do_action_type_id": "TD2",
"userId": "b5782c97fcabd9250fd5"
}
},
"clientList": {
"b5782c97fcabd9250fd5": {
"firstName": "test1656",
"lastName": "sap1903",
"userId": "b5782c97-fe64-440f-95a1-fcabd9250fd5",
"email": "47121552994774000@randomgenerated.com"
},
"290bd895fbc98e35cdc0": {
"firstName": "1903s6",
"lastName": "1903s6",
"userId": "290bd895-40b6-4f49-84f9-fbc98e35cdc0",
"email": "1903s6@mailinator.com"
}
},
"filteredCount": 2
}
我尝试使用HashMap
和Map
,但出现以下异常
例外:
java.lang.IllegalArgumentException:com.fasterxml.jackson.databind.JsonMappingException:无法从START_OBJECT令牌中反序列化java.util.ArrayList实例
我创建了以下POJO类
public class DetailsResponse implements Parcelable {
public DetailsResponse() {
}
private int filteredCount;
public HashMap<String, MeetingDetailsResponse> listofMeetings;
private HashMap<String, ContractInfo> clientList;
protected DetailsResponse(Parcel in) {
// ....
}
public static final Creator<DetailsResponse> CREATOR = new Creator<DetailsResponse>() {
// ...
};
public HashMap<String, ContractInfo> getClientList() {
return clientList;
}
public void setClientList(HashMap<String, ContractInfo> clientList) {
this.clientList = clientList;
}
public int getFilteredCount() {
return filteredCount;
}
public void setFilteredCount(int filteredCount) {
this.filteredCount = filteredCount;
}
public HashMap<String, MeetingDetailsResponse> getListofMeetings() {
return listofMeetings;
}
public void setListofMeetings(HashMap<String, MeetingDetailsResponse> listofMeetings) {
this.listofMeetings = listofMeetings;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
// ...
}
}
public class MeetingDetailsResponse implements Parcelable {
String to_do_order;
String to_do_action_type;
String to_do_action_type_id;
String userId;
public MeetingDetailsResponse() {
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
}
public static final Creator<MeetingDetailsResponse> CREATOR = new Creator<MeetingDetailsResponse>() {
@Override
public MeetingDetailsResponse createFromParcel(Parcel in) {
return new MeetingDetailsResponse(in);
}
@Override
public MeetingDetailsResponse[] newArray(int size) {
return new MeetingDetailsResponse[size];
}
};
protected MeetingDetailsResponse(Parcel in) {
}
public String getTo_do_order() {
return to_do_order;
}
public void setTo_do_order(String to_do_order) {
this.to_do_order = to_do_order;
}
public String getTo_do_action_type() {
return to_do_action_type;
}
public void setTo_do_action_type(String to_do_action_type) {
this.to_do_action_type = to_do_action_type;
}
public String getTo_do_action_type_id() {
return to_do_action_type_id;
}
public void setTo_do_action_type_id(String to_do_action_type_id) {
this.to_do_action_type_id = to_do_action_type_id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
public class ContactInfo implements Parcelable {
private String userId;
private String firstName;
private String lastName;
private String email;
public static final Creator<ContactInfo> CREATOR = new Creator<ContactInfo>() {
// ....
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
// ....
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}