我有带有布尔值(isBlocked(参数的JSON响应
{"isBlocked":true,"responseId":"ab123456789", "other":"irrelevant"}
My ResponseVO(使用Eclipse自动生成getter和setter(:
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResponseVO {
private boolean isBlocked;
private String responseId;
public boolean isBlocked() {
return isBlocked;
}
public void setBlocked(boolean isBlocked) {
this.isBlocked = isBlocked;
}
public String getResponseId() {
return responseId;
}
public void setResponseId(String responseId) {
this.responseId = responseId;
}
}
我正在使用ObjectMapper
设置VO对象
ResponseVO responseVO = new ObjectMapper().readValue(response, ResponseVO.class);
但是布尔参数设置为false而不是true
logger.debug("SpelPaus Block=" + responseVO.isBlocked());
将私有属性重命名为private boolean blocked;
并将getter设置为
public boolean isBlocked()
{return blocked;}
public void setBlocked(boolean blocked)
{this.blocked = blocked;}