JSONArray extends JSONElement implements Iterable<Object> { public Object get(int index) throws JSONException { return MAPPER.apply(obj.get(index)); } JSONArray();  JSONArray(String jsonString);  JSONArray(Collection<?> collection);  JSONArray(Object array);   JSONArray(JsonArray array);   JSONArray(JsonElement jsonElement); int length(); JSONArray put(JSONObject object); JSONArray put(JSONArray array); JSONArray put(double num); JSONArray put(int num); JSONArray put(long num); JSONArray put(float num); JSONArray put(Number num); JSONArray put(boolean bool); JSONArray put(String str); JSONArray put(Map map); JSONArray put(Collection collection); JSONArray put(T enumValue); JSONArray put(int index, long number); JSONArray put(int index, double number); JSONArray put(int index, boolean bool); JSONArray put(int index, Object object); JSONArray put(int index, float number); JSONArray put(int index, int number); JSONArray put(int index, Number number); JSONArray put(int index, String string); JSONArray put(int index, Map map); JSONArray put(int index, Collection collection); JSONArray put(int index, T enumValue); JSONArray put(Object object); Object remove(int index); boolean getBoolean(int index); boolean optBoolean(int index); boolean optBoolean(int index, boolean defaultValue); JSONObject getJSONObject(int index); JSONObject optJSONObject(int index); double getDouble(int index); double optDouble(int index); double optDouble(int index, double defaultValue); float getFloat(int index); float optFloat(int index); float optFloat(int index, float defaultValue); long getLong(int index); long optLong(int index); long optLong(int index, long defaultValue); Number getNumber(int index); Number optNumber(int index); Number optNumber(int index, Number defaultValue); int getInt(int index); int optInt(int index); int optInt(int index, int defaultValue); BigInteger getBigInteger(int index); BigInteger optBigInteger(int index, BigInteger defaultValue); BigDecimal getBigDecimal(int index); BigDecimal optBigDecimal(int index, BigDecimal defaultValue); String getString(int index); String optString(int index); String optString(int index, String defaultValue); JSONArray getJSONArray(int index); JSONArray optJSONArray(int index); T getEnum(Class<T> enumClass, int index); T optEnum(Class<T> enumClass, int index); T optEnum(Class<T> enumClass, int index, T defaultValue); Object get(int index); Object opt(int index); @Override String toString(); String toString(int indent); String join(String token); @Override Iterator<Object> iterator(); boolean similar(Object o); List toList(); boolean isNull(int index); boolean equals(Object o); int hashCode(); JSONObject toJSONObject(JSONArray names); boolean isEmpty();  }
@Test public void rawGet() { JSONArray array = new JSONArray(asList( 33.457848383, 1, "cheese", new JSONObject(of("foo", "bar")), new JSONArray(asList(1,2)))); assertThat(array.get(0), instanceOf(Double.class)); assertThat(array.get(1), instanceOf(Integer.class)); assertThat(array.get(2), instanceOf(String.class)); assertThat(array.get(3), instanceOf(JSONObject.class)); assertThat(array.get(4), instanceOf(JSONArray.class)); }