public static JSONObject fromObject(Object object, JsonConfig jsonConfig)
{
if(object == null || JSONUtils.isNull(object))
return new JSONObject(true);
if(object instanceof Enum)
throw new JSONException("'object' is an Enum. Use JSONArray instead");
if((object instanceof Annotation) || object != null && object.getClass().isAnnotation())
throw new JSONException("'object' is an Annotation.");
if(object instanceof JSONObject)
return _fromJSONObject((JSONObject)object, jsonConfig);
if(object instanceof DynaBean)
return _fromDynaBean((DynaBean)object, jsonConfig);
if(object instanceof JSONTokener)
return _fromJSONTokener((JSONTokener)object, jsonConfig);
if(object instanceof JSONString)
return _fromJSONString((JSONString)object, jsonConfig);
if(object instanceof Map)
return _fromMap((Map)object, jsonConfig);
if(object instanceof String)
return _fromString((String)object, jsonConfig);
if(JSONUtils.isNumber(object) || JSONUtils.isBoolean(object) || JSONUtils.isString(object))
return new JSONObject();
if(JSONUtils.isArray(object))
throw new JSONException("'object' is an array. Use JSONArray instead");
else
return _fromBean(object, jsonConfig);
}
很好奇,问什么JSONObject的fromObject抛出异常,没有捕捉?