[quote=引用 6 楼 qq_36593018 的回复:] [quote=引用 5 楼 dalor 的回复:] [quote=引用 3 楼 qq_36593018 的回复:] public void onResponse(Call call, Response response) throws IOException { final String res = response.body().string(); L.e("onResponse:" + res); try { JSONArray jsonArray = new JSONArray(res); for (int i = 0; i <jsonArray.length() ; i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); String id =jsonObject.getString("id"); L.e("+++++++++++++++++++"+id+"+++++++++++++++++++"); } } catch (JSONException e) { e.printStackTrace(); } } 我这样为什么不能得到id
[quote=引用 5 楼 dalor 的回复:] [quote=引用 3 楼 qq_36593018 的回复:] public void onResponse(Call call, Response response) throws IOException { final String res = response.body().string(); L.e("onResponse:" + res); try { JSONArray jsonArray = new JSONArray(res); for (int i = 0; i <jsonArray.length() ; i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); String id =jsonObject.getString("id"); L.e("+++++++++++++++++++"+id+"+++++++++++++++++++"); } } catch (JSONException e) { e.printStackTrace(); } } 我这样为什么不能得到id
[quote=引用 3 楼 qq_36593018 的回复:] public void onResponse(Call call, Response response) throws IOException { final String res = response.body().string(); L.e("onResponse:" + res); try { JSONArray jsonArray = new JSONArray(res); for (int i = 0; i <jsonArray.length() ; i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); String id =jsonObject.getString("id"); L.e("+++++++++++++++++++"+id+"+++++++++++++++++++"); } } catch (JSONException e) { e.printStackTrace(); } } 我这样为什么不能得到id
public void onResponse(Call call, Response response) throws IOException { final String res = response.body().string(); L.e("onResponse:" + res); try { JSONArray jsonArray = new JSONArray(res); for (int i = 0; i <jsonArray.length() ; i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); String id =jsonObject.getString("id"); L.e("+++++++++++++++++++"+id+"+++++++++++++++++++"); } } catch (JSONException e) { e.printStackTrace(); } } 我这样为什么不能得到id
整个先转化成json对象,再获取data数组,再遍历数组,转化成JSON对象,根据key,也就是‘id’,获取值。 API:JSONObject JSONArray
80,337
社区成员
91,284
社区内容
加载中
试试用AI创作助手写篇文章吧