在解析JSON时,JSONObject可以调用两个方法
public String getString(String name) throws JSONException {
throw new RuntimeException("Stub!");
}
public String optString(String name) {
throw new RuntimeException("Stub!");
}
这两个方法实现的功能一样,只是在没有值时,getString() 直接抛出错误(org.json.JSONException),而optString()返回一个空值。
原文:https://www.cnblogs.com/bugzj/p/11451096.html