How Can i Chek element is jsonobject or jsonarray in android?

view story

http://stackoverflow.com – i want to access AmenityCodes you can see in the image for 0 position Amenity Codes is Array but on 49 positiin is json object so how to chek this is object or json array 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); (HowTos)