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 class
JsonArray.DefaultJsonArray
Instances of this class are used as default representations for JSON arrays.static class
JsonArray.JsonArrayWrapper
Instances of this class are used as default representations for JSON arrays.
-
Field Summary
Fields Modifier and Type Field Description static JsonArray
EMPTY_ARRAY
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description JsonArray
append(Object value)
Stream<JsonArray>
arrayStream()
Streams the elements in the array after casting them toJsonArray
s.JsonArray
asArray(int index)
boolean
asBoolean(int index)
double
asDouble(int index)
float
asFloat(int index)
int
asInt(int index)
long
asLong(int index)
String
asString(int index)
List<Object>
backing()
static JsonArray
create()
Creates a new instance of theJsonArray.DefaultJsonArray
.static JsonArray
from(List<Object> backing)
Creates a wrapper around an existingList<Object>
.static JsonArray
from(JsonArray.DefaultJsonArray backing)
Overloaded to ensure that an existingJsonArray.DefaultJsonArray
is not wrapped again.Object
get(int index)
int
size()
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.DefaultJsonArray
is 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 toJsonArray
s.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)
-
-