0
我試圖從reddit(https://www.reddit.com/r/gifs/.json)從json文件中獲取數據。但我不斷收到同樣的錯誤:org.json.JSONException:沒有值的兒童
org.json.JSONException: No value for children
這是我的代碼:
RequestQueue queue = Volley.newRequestQueue(this);
String url ="https://www.reddit.com/r/funny.json";
JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray children = response.getJSONArray("children");
} catch (JSONException e) {
e.printStackTrace();
Log.i(TAG, "ERROR !!!!" + e);
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.i(TAG, "ERROR");
}
});
queue.add(jsObjRequest);
如果有人能幫助我就好!
權的孩子,因爲'children' 'JSONArray'在數據''JSONObject'內部 –