我得到以下从服务器生成的响应cakephp
[
{
"id": "42389",
"start": "0000-00-00",
"end": "0000-00-00",
"event_id": null,
"trip_id": "5791",
"location_id": "231552",
"user_id": "105",
"users_attending": "0",
"user_local": "0",
"Trip": {
"name": "Asdas"
},
"Event": [],
"Location": {
"name": "South Melbourne"
}
},
{
"id": "42392",
"start": "0000-00-00",
"end": "0000-00-00",
"event_id": "1218",
"trip_id": "4772",
"location_id": "271505",
"user_id": "105",
"users_attending": "3",
"user_local": "50",
"Trip": {
"name": "trip by 1059200"
},
"Event": {
"title": "SampleEvent 454",
"id": "1218"
},
"Location": {
"name": "Houston"
}
},
.......
]
问题是解析器需要Event
对象,但如果是,null
那么它正在接收空数组。
由于响应是由 自动生成的cakephp
,因此必须在服务器端的很多地方进行更改。
Event
如果它是一个空数组,杰克逊是否有任何简单的方法来忽略属性?
编辑:
我尝试过拥有两个带有Event
名称的属性:一个数组和另一个对象,但这也不起作用。