【发布时间】:2015-09-10 04:15:54
【问题描述】:
我有以下 JSON(来自 WebService):
{
"result": "success",
"users": [{
"id": 12345,
"login": "blabla",
"firstName": "first name here",
"lastName": "last name here",
"companyName": "company here",
"email": "email_here@test.com",
"phone": "",
"mobile": "123456789",
"locations": [{
"id": 123123,
"latitude": 23.330196,
"longitude": -92.026073,
"timestamp": "2015-08-17T01:43:21+00:00"
}],
"status": {
"message": "Message here",
"timestamp": "2015-07-31T01:50:51+00:00"
}
}, (...)
我还有以下 bean:
@JsonTypeName("user")
public class User implements IdentityInterface
{
private long id;
@JsonProperty
private String firstName;
(...)
//How can I anotate this field?
private double latitude;
//How can I anotate this field?
private double longitude;
(...)
}
我不能只将@JsonProperty 放在纬度/经度变量中,因为这些值在 JSON 的“位置”部分内。
如何在此处使用 Jackson 注释纬度/经度字段?
【问题讨论】:
标签: java json parsing annotations jackson