Package org.jdrupes.json
Interface JsonArray
-
- All Known Implementing Classes:
JsonArray.DefaultJsonArray,JsonArray.JsonArrayWrapper
public interface JsonArray
A view on aList<Object>that provides some utility methods for accessing the data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classJsonArray.DefaultJsonArrayInstances of this class are used as default representations for JSON arrays.static classJsonArray.JsonArrayWrapperInstances of this class are used as default representations for JSON arrays.
-
Field Summary
Fields Modifier and Type Field Description static JsonArrayEMPTY_ARRAY
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description JsonArrayappend(Object value)Stream<JsonArray>arrayStream()Streams the elements in the array after casting them toJsonArrays.JsonArrayasArray(int index)booleanasBoolean(int index)doubleasDouble(int index)floatasFloat(int index)intasInt(int index)longasLong(int index)StringasString(int index)List<Object>backing()static JsonArraycreate()Creates a new instance of theJsonArray.DefaultJsonArray.static JsonArrayfrom(List<Object> backing)Creates a wrapper around an existingList<Object>.static JsonArrayfrom(JsonArray.DefaultJsonArray backing)Overloaded to ensure that an existingJsonArray.DefaultJsonArrayis not wrapped again.Objectget(int index)intsize()Stream<Object>stream()Streams the elements in the array.
-
-
-
Field Detail
-
EMPTY_ARRAY
static final JsonArray EMPTY_ARRAY
-
-
Method Detail
-
create
static JsonArray create()
Creates a new instance of theJsonArray.DefaultJsonArray.- Returns:
- the json array
-
from
static JsonArray from(List<Object> backing)
Creates a wrapper around an existingList<Object>.- Parameters:
backing- the backing list- Returns:
- the json array
-
from
static JsonArray from(JsonArray.DefaultJsonArray backing)
Overloaded to ensure that an existingJsonArray.DefaultJsonArrayis not wrapped again.- Parameters:
backing- the backing list- Returns:
- the argument
-
size
int size()
-
arrayStream
Stream<JsonArray> arrayStream()
Streams the elements in the array after casting them toJsonArrays.Useful for processing arrays of arrays.
- Returns:
- the stream
-
asInt
int asInt(int index)
-
asLong
long asLong(int index)
-
asBoolean
boolean asBoolean(int index)
-
asFloat
float asFloat(int index)
-
asDouble
double asDouble(int index)
-
-