我想访问AmenityCodes你可以在图像中看到0位置Amenity Codes是Array但是49 positiin是json对象所以如何chek这是对象或json数组
MyActivity.java
for(int r=0;r<results.length();r++)
{
HashMap<String, String> map = new HashMap<String, String>();
hotelrating=results.getJSONObject(r).get(TAG_STARRATING).toString();
deeplink=results.getJSONObject(r).get(TAG_HOTELDEEPLINK).toString();
JSONArray amenityarray=results.getJSONObject(r).getJSONArray(TAG_AMENITYCODES);
Log.e("Amenitiescode","-->"+amenityarray);
}
答案 0 :(得分:1)
替换:
JSONArray amenityarray=results.getJSONArray(r);
使用:
JSONArray amenityarray=results.getJSONObject(r).getJSONArray("AmenityCodes");