org.springframework.http.converter.HttpMessageNotWritableException:
Could not write JSON: Object is null (through reference chain:
net.sf.json.JSONObject["rows"]->net.sf.json.JSONArray[0]->net.sf.json.JSONObject["checkTime"]->net.sf.json.JSONNull["empty"]);
nested exception is org.codehaus.jackson.map.JsonMappingException:
Object is null (through reference chain: net.sf.json.JSONObject["rows"]->net.sf.json.JSONArray[0]->net.sf.json.JSONObject["checkTime"]->net.sf.json.JSONNull["empty"])
我是因为数据库中数据字段checkTime为null,所以在数据转换成jsonObject的时候出现了JSONNul异常。
大家可以使用com.alibaba.fastjson.JSONObject.parseObject进行json格式化,
我是直接用同样的key覆盖掉了之前的"checkTime",并赋值为空字符串就没问题了
如下图: