net.sf.json.JSONException: Object is null

Map agreementMap = new HashMap<String, Object>();
jsonObject = JSONObject.fromObject(agreementMap);

return SUCCESS;


如果map的value值为空,会出现上述错误

解决


	//防止json转换时为null值的错误
	private Object isNull(Object obj) {
		
		if (obj == null) {
			return "";
		}
		
		return obj;
	}

你可能感兴趣的:(exception)