无法通过从 JsonObject 获取值来编译代码

Can't compile the code with getting the value from JsonObject

我使用 Volley 库向 Google 个地方发出 API 请求。 响应是这样的对象:

{
    "html_attributions": [],
    "results": [
        {
          "address":  "Wood Quay, Dublin, Ireland",
          "name":     "Christ Church Cathedral",
          "place_id": "ChIJGw9ASiYMZ0gRy9yiaCZxNZI",
        },
        { ... },
        { ... },
    ],
    "status": "OK"
}

Response.Listener 中,我需要访问 "results" 数组。
我尝试获取名称为 "results" 的 JSONArray,如下所示:

    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, API_URL, null,
        new Response.Listener <JSONObject> () {
            @Override
            public void onResponse(JSONObject response) {

                // THE PROBLEM IS HERE - WON'T COMPILE !!!
                JSONArray array = response.getJSONArray("results");
            }
        },
        new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                //
            }
        });

但是我看到一个错误:

似乎 response.getJSONArray("results"); 抛出了 JSONException。您需要通过用 try-catch 块包装 response.getJSONArray("results"); 来处理该异常。

像这样:

 try {
    JSONArray array = response.getJSONArray("results");
} catch (org.json.JSONException exception) {
    //  handle the exception
}