【发布时间】:2014-06-19 13:45:12
【问题描述】:
我有以下 JSON,我想将其映射到一个对象。
{
"response": {
"original": {
"status": {
"code": "SUCCESS"
},
"organisationNode": [
{
"organisationId": {
"identifier": "2005286047",
"identifierType": "BECBE"
},
"organisationLevel": "Subdivision",
"organisationCode": "ENT_CBE",
"organisationParentNode": {
"organisationId": {
"identifier": "0878016185",
"identifierType": "BEEUN"
},
"organisationLevel": "Entity",
"organisationCode": "ENT_CBE"
}
}
]
}
}
}
我希望我的 Java 对象看起来像这样:
public class Structure {
private String status; //SUCCESS
private List<OrganisationNode> organisationNodes;
public class OrganisationNode {
private String organisationId; //2005286047
private String organisationLevel; //Subdivision
private List<OrganisationNode> organisationNodes;
}
}
是否有某种 Jackson 注释可以查看,例如:
@SomeAnnotation("response.original.status.code")
private String status;
我正在使用这样的 restTemplate 调用 JSON 服务(它为我提供上面的 JSON 响应):
ResponseEntity<Structure> response = restTemplate.postForEntity(endpoint, requestObject, Structure.class);
【问题讨论】:
标签: java json mapping jackson resttemplate