Java Jersey Jackson无法识别的属性异常(Json)
我收到Expedia EAN服务的以下回复Java Jersey Jackson无法识别的属性异常(Json),java,jackson,jersey-client,Java,Jackson,Jersey Client,我收到Expedia EAN服务的以下回复 { "HotelListResponse": { ...... "HotelList": { "@size": "200", "@activePropertyCount": "293", "HotelSummary": [....] .... } 我的Jersey客户端中的以下代码 public <T> T get(String getUrl, Class
{
"HotelListResponse": {
......
"HotelList": {
"@size": "200",
"@activePropertyCount": "293",
"HotelSummary": [....]
....
}
我的Jersey客户端中的以下代码
public <T> T get(String getUrl, Class<T> t) throws HttpOperationException{
WebResource webResource = client.resource(getUrl);
ClientResponse response = webResource
.accept(MediaType.APPLICATION_JSON)
.get(ClientResponse.class);
T output = response.getEntity(t);
System.out.println(output);
if(response.getStatus() != 200) {
throw new HttpOperationException(
response.getStatus(), output.toString());
}
return (T)output;
}
public T get(字符串getUrl,类T)抛出HttpOperationException{
WebResource=client.resource(getUrl);
ClientResponse响应=webResource
.accept(MediaType.APPLICATION_JSON)
.get(ClientResponse.class);
T输出=response.getEntity(T);
系统输出打印项次(输出);
if(response.getStatus()!=200){
抛出新的HttpOperationException(
response.getStatus(),output.toString());
}
返回(T)输出;
}
我调用了传递hotellistrensponse.class和Wrapper.class的客户端,我创建了它们作为hotellistrensponse.class的容器,这两个容器都崩溃了,错误如下
线程“main”中出现异常
org.codehaus.jackson.map.exc.UnrecognizedPropertyException:
无法识别的字段“HotelListResponse”(类
in.xxx.xxxxxx.port.adapter.expedia.hotels.list.response.Wrapper),而不是
被标记为可忽略的
我的对象模型搞错了吗?你能显示hotellistreponse.class和Wrapper.class吗?我能够诊断这个问题,这是因为属性是有条件返回的,包括
@JsonIgnoreProperties(ignoreUnknown=true)