我无法反序列化这个:
{
"backup_times":{
"12":{
"time":"2012-12-20 11:52:01",
"status":"T"
},
"2":{
"time":"2012-12-20 11:22:57",
"status":"T"
},
"3":{
"time":"2012-12-20 11:23:35",
"status":"T"
},
"13":{
"time":"2012-12-20 11:52:57",
"status":"T"
},
"9":{
"time":"2012-12-20 11:46:09",
"status":"T"
},
"4":{
"time":"2012-12-20 11:28:53",
"status":"T"
},
"5":{
"time":"2012-12-20 11:30:53",
"status":"T"
},
"10":{
"time":"2012-12-20 11:48:30",
"status":"T"
},
"11":{
"time":"2012-12-20 11:49:57",
"status":"T"
}
}
}
这种结构是否可以将其转换为自定义类?
这是我目前拥有的当前 java 类,它基本上包含字符串的 hashmap 作为键和 Job 子类作为值:
public class RestoreDatesJsonReader {
private HashMap<String, Job> backupTimes;
public static class Job {
private String time;
private String status;
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
public HashMap<String,Job> getBackupTimes() {
return backupTimes;
}
public void setBackupTimes(HashMap<String, Job> backup_times) {
this.backupTimes = backup_times;
}
}