【发布时间】:2018-06-06 16:05:06
【问题描述】:
我有getter方法
@JsonInclude(Include.NON_NULL)
public Date getVerifiedFrom() {
if(invoices == null || invoices.isEmpty()) {
return null;
}
return invoices.stream().filter(i->i.getVerifiedDate() != null).map(Invoice::getVerifiedDate).min(Date::compareTo).get();
}
我尝试了几个链接,但没有帮助,
http://www.java2novice.com/java-json/jackson/ignore-json-null-elements/
How to deserialize Jackson Json NULL String to Date with JsonFormat
How to tell Jackson to ignore a field during serialization if its value is null?
错误:
Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No value present;
nested exception is com.fasterxml.jackson.databind.JsonMappingException: No value present (through reference chain: java.util.ArrayList[0]->com.enkindle.service.resource.TradeDebtResource["verifiedFrom"])
【问题讨论】:
-
你试过在字段上添加注解而不是getter方法吗?
标签: java spring spring-boot jackson2