我的json看起来像:
[
{
"schedule":[
{
"amount":19.98,
"due_at":null,
"identifier":"1549b45ff814e181dcbb983a02b35e9b3dd276fc-1",
"paid_at":"2012-01-24",
"status":"paid"
}
]
},
{
"schedule":[
{
"amount":24.68,
"due_at":null,
"identifier":"1549fdfdf814e181dcbb983a02b35e9b3dd276fc-1",
"paid_at":"2012-08-14",
"status":"paid"
}
]
}
]
我的日程安排模式:
public class Schedule {
public double amount;
public String due_at;
public String identifier;
public String paid_at;
public String status;
}
我的日程安排模型:
public class Schedules extends HashMap<String, ArrayList<Schedule>>{
private static final long serialVersionUID = 1L;
}
现在我用:
ListSchedules objectMapper.readValue = (jp, new TypeReference <Schedules> () {});
但它不起作用,有人可以告诉我要走的路吗
答案 0 :(得分:1)
修改为以下内容
对象数组
Schedule[] objects = objectMapper.readValue(jp, Schedule[].class);
对象列表
List<Schedule> objects =
objectMapper.readValue(jp, new TypeReference<List<Schedule>>(){})
*假设jp
是jason text