2 回答
TA贡献1807条经验 获得超9个赞
在这里,您将获得 JSONObject,因此您可以将其转换为
JSONArray jsonArray = new JSONArray(readlocationFeed);
line with following
JSONObject jsnobject = new JSONObject(readlocationFeed);
and after
JSONArray jsonArray = jsnobject.getJSONArray("locations");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject explrObject = jsonArray.getJSONObject(i);
}
您可以在 Arraylist 上添加此对象。
TA贡献1803条经验 获得超6个赞
This will help you.
JSONArray jsonArrayList = new JSONArray();
ArrayList<String> label=new ArrayList<>();
JSONArray jsonArray = new JSONArray(readlocationFeed);
if(jsonArray.length()>0){
for(int i=0;i<jsonArray.length();i++){
JSONArray jsonArrayForValue = new JSONArray(jsonArray.get(i));
if(i==0){
////////**********For Label/Header*******///////////
for(int j=0;j<jsonArrayForValue.length();j++){
label.add(jsonArrayForValue.get(j));
}
}else{
JSONObject eachDeatail=new JSONObject();
for(int j=0;j<jsonArrayForValue.length();j++){
eachDeatail.put(label.get(j),jsonArrayForValue.get(label.get(j)).toString());
}
jsonArrayList.add(eachDeatail);
}
}
}
添加回答
举报