我需要能够从我已经拥有的 JSONArray 创建一个新的 JSONArray,在数组中我有很多称为 id 的字段,每行还有一个,我如何获得它们的列表?
例如。我把这个拿回来
[{"id":111,"users":"blob"},
{"id":111,"users":"blob"},
{"id":111,"users":"blob"},
{"id":111,"users":"blob"},
{"id":111,"users":"blob"},
{"id":111,"users":"blob"}]
我将如何获得仅 ID 的列表?
- 编辑
决定在此之后直接使用 for 循环,但谢谢:D
HttpResponse response = httpclient.execute(httpget); //execute the HttpPost request
JSONArray jsa = projectResponse(response); //get the json response
for(int i = 0; i < jsa.length(); i++){
JSONObject jso = jsa.getJSONObject(i);
publishProgress(jso.getString("id"), jso.getString("name"));
}