这个错误是JSONObject对象判断为null不成立 引起的
JSONObject jsonObject = JSONObject.fromObject(" null");
System.out.println(jsonObject);
// jsonObject为空 引起 null object
System.out.println(jsonObject.getString("code"));
// 此时需要加个判断
if(jsonObject.isNullObject()) {
System.out.println("jsonObject 为空");
}else {
System.out.println(jsonObject.getString("code"));
}
Exception in thread "main" net.sf.json.JSONException: null object
at net.sf.json.JSONObject.verifyIsNull(JSONObject.java:2744)
at net.sf.json.JSONObject.getString(JSONObject.java:2087)