/optJSONObject源码解析:
 /**
 *Returns the value mapped by {@code name} if it exists and is a {@code
 *JSONObject}. Returns null otherwise.
 */
publicJSONObject optJSONObject(String name) {
    Objectobject = opt(name);
    returnobject instanceof
JSONObject ? (JSONObject) object : null;
}
//当返回值不是JSONObject对象时,返回值为null,不抛出异常;//getJSONObject源码解析:
 /**
 *Returns the value mapped by {@code name} if it exists and is a {@code
 *JSONObject}.
 *@throws JSONException if the mapping doesn't exist or is not a {@code
 *JSONObject}.
 */
publicJSONObject getJSONObject(String name) throws
JSONException {
    Objectobject = get(name);
    if(object instanceof
JSONObject) {
        return(JSONObject) object;
    }else
{
        throwJSON.typeMismatch(name, object, "JSONObject");
    }
}
//当返回值不是JSONObject对象时,抛出异常;