`

org.codehaus.jackson.map.JsonMappingException: null object

阅读更多

 

     程序错误,仅作为个人记录。

错误信息: null object (through reference chain: com.model.ResponseBean["message"]->net.sf.json.JSONArray[1]) 
返回 
点击这里查看具体错误消息,报告以下错误消息给系统管理员,可以更加快速的解决问题

org.codehaus.jackson.map.JsonMappingException: null object (through reference chain: com.model.ResponseBean["message"]->net.sf.json.JSONArray[1])
 at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:218)
 at org.codehaus.jackson.map.JsonMappingException.wrapWithPath(JsonMappingException.java:197)
 at org.codehaus.jackson.map.ser.std.SerializerBase.wrapAndThrow(SerializerBase.java:166)
 at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:81)
 at org.codehaus.jackson.map.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:23)
 at org.codehaus.jackson.map.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:86)
 at org.codehaus.jackson.map.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:446)
 at org.codehaus.jackson.map.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:150)
 at org.codehaus.jackson.map.ser.BeanSerializer.serialize(BeanSerializer.java:112)
 at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:610)
 at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
 at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:1613)

 

     问题原因:返回json数据存在为null的数据元素。

     解决:

// 过滤为null的元素
List listResult = new ArrayList();
for (int i = 0; i < counts.size(); i ++) {
	if(counts.get(i)  != null){
		listResult.add(counts.get(i));
	} else {
		listResult.add(0);
	}
}

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics