我在java类下面有json注释。
toy_sep<-toy %>%
separate(Alt ,
into=LETTERS[1:5],
sep="\\|",
extra="merge",
remove=FALSE) %>%
gather(Alias_id,Alias,A:E) %>%
mutate(Match=apply(t(Alias),
2,
FUN = function(x){
ind=grep(x,toy$Name)
ifelse(!is.na(sum(ind))&length(ind) >= 1 ,
paste0(ind,collapse = "|"),
NA)
}
)
)
matches<-toy_sep[complete.cases(toy_sep),]
以下是从服务器返回的json字符串。
public class NotificationResponse {
@JsonProperty(
value = "TransactionId",
required = false
)
private String transactionId;
@JsonProperty(
value = "DateTime",
required = true
)
private DateTime dateTime;
@JsonProperty(
value = "Status",
required = true
)
private String status;
@JsonProperty(
value = "EventType",
required = true
)
private String eventType;
@JsonProperty(
value = "ItineraryNumber",
required = false
)
private String itineraryNumber;
@JsonProperty(
value = "ConfirmationNumber",
required = false
)
private String confirmationNumber;
public NotificationResponse() {
}
}
我希望将此字符串转换为上述对象,并使用下面的代码进行转换。
{"TransactionId": "f06edfa3-27f4-44e6-838c-b8dd3d0a3210","Date": "2016-11-21T02:05:00+0000","Status": "SUCCESS","EventType": "CANCEL","ItineraryNumber": "7152088262"}
但我得到的NotificationResponse对象映射为元素的空值。
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper.readValue(response, NotificationResponse.class);
有人可以帮我解决这个问题吗?