我正在尝试反序列化具有以下结构的json文件: 包含嵌套对象字符串(时间轴)和其他数据的对象(事件)字符串
输入:
[
{
"id": "6590d474-00bc-4ec9-8386-5f23b834a4ac",
"subject": "lists-webapp error rate jump to 15% an hour ago",
"reporter": "erezp@google.com",
"reportTime": "2017-04-13T07:04:52.742Z",
"type": "incident",
"status": "resolved",
"__v": 0
},
{
"id": "05c0be2b-8441-4d89-bdff-5d98b3ba1358",
"subject": "FYI Viewer success rate drop in Peru",
"reporter": "dansh@google.com",
"reportTime": "2017-03-24T11:55:59.870Z",
"type": "incident",
"status": "resolved",
"__v": 0
},
{
"id": "1437f281-3da0-49da-b95e-c06bf9b83dfe",
"subject": "Is App market down?",
"reporter": "yaelra@google.com",
"reportTime": "2017-04-13T12:57:17.864Z",
"type": "incident",
"status": "resolved",
"__v": 2,
"timeline": [
{
"dateTime": "2017-05-10T11:55:43.782Z",
"updatedFieldName": "status",
"newVal": "resolved",
"oldVal": "investigating",
"modifiedBy": "{\"email\":\"shaik@google.com\",\"displayName\":\" Kfir\",\"imageUrl\":\"https://lh4.googleusercontent.com/-tSa00bTac8M/AAAAAAAAdAAI/AAAAAAAAA4s/pxvoRPGswGI/photo.jpg?sz=50\",\"accessToken\":\"\"}",
"note": "Kfir did something",
"_id": "5912ffbfea7fdb0010091b0a"
}
]
},
{
"id": "5c45ed34-1637-44c0-90cc-6b5b818272d3",
"subject": "Re: Users report phishing block on social media",
"reporter": "idoi@google.com",
"reportTime": "2017-04-14T14:41:37.798Z",
"type": "incident",
"status": "resolved",
"__v": 1,
"timeline": [
{
"dateTime": "2017-05-11T09:37:41.444Z",
"updatedFieldName": "status",
"newVal": "resolved",
"oldVal": "reported",
"modifiedBy": "{\"email\":\"elip@google.com\",\"displayName\":\" Ponyatovski\",\"imageUrl\":\"https://lh4.googleusercontent.com/-MZ8WHdVK1NM/AAAAsAAAAAAI/AAAAAAAAABM/sDo5Dj05bDk/photo.jpg?sz=50\",\"accessToken\":\"\"}",
"_id": "591430e55ee8b90010030615"
}
]
},
{
"id": "ff22ec2e-c717-4e28-b3a4-8c7c9c791248",
"subject": "Unable to create new site from my account",
"reporter": "doronbt@google.com",
"reportTime": "2017-05-08T12:07:55.733Z",
"type": "incident",
"status": "resolved",
"timeline": [
{
"updatedFieldName": "status",
"modifiedBy": "doronbt@google.com",
"newVal": "reported",
"dateTime": "2017-05-08T12:07:55.733Z",
"_id": "59105f9b1029b7001088c29e"
},
{
"dateTime": "2017-05-10T13:38:20.229Z",
"updatedFieldName": "status",
"newVal": "resolved",
"oldVal": "investigating",
"modifiedBy": "{\"email\":\"elip@google.com\",\"displayName\":\" Ponyatovski\",\"imageUrl\":\"https://lh4.googleusercontent.com/-MZ8WHdVK1NM/AAAsAAAAAAAI/AAAAAAAAABM/sDo5Dj05bDk/photo.jpg?sz=50\",\"accessToken\":\"\"}",
"_id": "591317cc4dea7f000fdbb28d"
}
],
"__v": 2
}
]
我还为事件和时间线创建了相关的课程:
public class Incident {
private String reportTime;
private String reporter;
private String id;
private String status;
private String subject;
private String __v;
private String type;
private Timeline[] timeline;
}
public class Timeline {
private String updatedFieldName;
private String newVal;
private String oldVal;
private String note;
private String dateTime;
private String modifiedBy;
}
我设法使用单个时间轴对象获得单个事件,但它不适用于多个对象。 也许将时间轴存储在数组中导致了这个问题?