使用默认ObjectMapper后,布尔JSON参数为false



我有带有布尔值(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;}

相关内容

  • 没有找到相关文章

最新更新