在这里location是一个JsonArray对象。所以使用整数变量来访问它的数据:)
ArrayList<String> data=new ArrayList<String>(); for(int i=0;i<location.length();i++){ JSONObject arrayElement=location.getJSONObject(i); data.add(arrayElement.getString("place_name")); Log.i("json",data.get(i)); }
更改 Log.d(location.getJSONObject("place_name"));
Log.d(location.getJSONObject("place_name"));
至
Log.d(location.getJSONObject(i).getString("place_name");