public interface JsonArray extends JsonStructure, List<JsonValue>
[1,5,8]or
[
{"name":"karl", "age": 38},
{"name":"sue", "age": 42},
]
JsonValue.ValueTypeEMPTY_JSON_ARRAY, EMPTY_JSON_OBJECT, FALSE, NULL, TRUE| Modifier and Type | Method and Description |
|---|---|
boolean |
getBoolean(int index) |
boolean |
getBoolean(int index,
boolean defaultValue) |
int |
getInt(int index) |
int |
getInt(int index,
int defaultValue) |
JsonArray |
getJsonArray(int index) |
JsonNumber |
getJsonNumber(int index) |
JsonObject |
getJsonObject(int index) |
JsonString |
getJsonString(int index) |
String |
getString(int index) |
String |
getString(int index,
String defaultValue) |
<T extends JsonValue> |
getValuesAs(Class<T> clazz) |
default <T,K extends JsonValue> |
getValuesAs(Function<K,T> func)
Returns a list for the array.
|
boolean |
isNull(int index) |
getValueasJsonArray, asJsonObject, getValueType, toStringadd, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArrayparallelStream, removeIf, streamJsonObject getJsonObject(int index)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to the JsonObjectJsonArray getJsonArray(int index)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to the JsonArrayJsonNumber getJsonNumber(int index)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to the JsonNumberJsonString getJsonString(int index)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to the JsonString<T extends JsonValue> List<T> getValuesAs(Class<T> clazz)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to the given slazzdefault <T,K extends JsonValue> List<T> getValuesAs(Function<K,T> func)
func argument.
This method can be used to obtain a list of the unwrapped types, such as
List<String> strings = ary1.getValuesAs(JsonString::getString);
List<Integer> ints = ary2.getValuesAs(JsonNumber::intValue);
It can also be used to obtain a list of simple projections, such as
Lsit<Integer> stringsizes = arr.getValueAs((JsonString v) -> v.getString().length();
K - The element type (must be a subtype of JsonValue) of this JsonArray.T - The element type of the returned Listfunc - The function that maps the elements of this JsonArray to the target elements.ClassCastException - if the JsonArray contains a value of wrong typeString getString(int index)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to a StringString getString(int index, String defaultValue)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to a Stringint getInt(int index)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to an intNullPointerException - if an object with the given name doesn't existint getInt(int index,
int defaultValue)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to an intboolean getBoolean(int index)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to a booleanNullPointerException - if an object with the given name doesn't existboolean getBoolean(int index,
boolean defaultValue)
IndexOutOfBoundsException - if the index is out of rangeClassCastException - if the value at the specified position is not
assignable to a booleanboolean isNull(int index)
JsonValue.NULL.IndexOutOfBoundsException - if the index is out of rangeCopyright © 2010 - 2020 Adobe. All Rights Reserved