Package playn.core
Interface Json.Array
- Enclosing interface:
Json
public static interface Json.Array
Represents a parsed JSON array as a simple
int->value
map.-
Method Summary
Modifier and TypeMethodDescriptionInserts a JSON boolean, null, number, object, or array value at the given index.Appends a JSON boolean, null, number, object, or array value.getArray
(int index) Gets the array value at the given index, ornull
if there is no value at this index.<T> Json.TypedArray<T>
Gets an array at the given index that assumes its values are of the given json type, ornull
if there is no value at this index.getArray
(int index, Json.Array dflt) Gets the array value at the given index, or the default if there is no value at this index.boolean
getBoolean
(int index) Gets the boolean value at the given index, orfalse
if there is no value at this index.boolean
getBoolean
(int index, boolean dflt) Gets the boolean value at the given index, or the default if there is no value at this index.double
getDouble
(int index) Gets the double value at the given index, or0
if there is no value at this index.double
getDouble
(int index, double dflt) Gets the double value at the given index, or the default if there is no value at this index.int
getInt
(int index) Gets the integer value at the given index, or0
if there is no value at this index.int
getInt
(int index, int dflt) Gets the integer value at the given index, or the default if there is no value at this index.long
getLong
(int index) Gets the long value at the given index, or0
if there is no value at this index.long
getLong
(int index, long dflt) Gets the long value at the given index, or the default if there is no value at this index.float
getNumber
(int index) Gets the float value at the given index, or0
if there is no value at this index.float
getNumber
(int index, float dflt) Gets the float value at the given index, or the default if there is no value at this index.getObject
(int index) Gets the object value at the given index, ornull
if there is no value at this index.getObject
(int index, Json.Object dflt) Gets the object value at the given index, or the default if there is no value at this index.getString
(int index) Gets the string value at the given index, ornull
if there is no value at this index.Gets the string value at the given index, or the default if there is no value at this index.boolean
isArray
(int index) Returnstrue
if the value at the given index is an array.boolean
isBoolean
(int index) Returnstrue
if the value at the given index is a boolean.boolean
isNull
(int index) Returnstrue
if the value at the given index is null, or does not exist.boolean
isNumber
(int index) Returnstrue
if the value at the given index is a number.boolean
isObject
(int index) Returnstrue
if the value at the given index is an object.boolean
isString
(int index) Returnstrue
if the value at the given index is a string.int
length()
Gets the length of this array.remove
(int index) Removes a JSON value from the given index.Sets a JSON boolean, null, number, object, or array value at the given index.<T extends playn.core.json.JsonSink<T>>
playn.core.json.JsonSink<T>write
(playn.core.json.JsonSink<T> sink) Writes this object to aJsonSink
.
-
Method Details
-
length
int length()Gets the length of this array. -
getBoolean
boolean getBoolean(int index) Gets the boolean value at the given index, orfalse
if there is no value at this index. -
getBoolean
boolean getBoolean(int index, boolean dflt) Gets the boolean value at the given index, or the default if there is no value at this index. -
getNumber
float getNumber(int index) Gets the float value at the given index, or0
if there is no value at this index. -
getNumber
float getNumber(int index, float dflt) Gets the float value at the given index, or the default if there is no value at this index. -
getDouble
double getDouble(int index) Gets the double value at the given index, or0
if there is no value at this index. -
getDouble
double getDouble(int index, double dflt) Gets the double value at the given index, or the default if there is no value at this index. -
getInt
int getInt(int index) Gets the integer value at the given index, or0
if there is no value at this index. -
getInt
int getInt(int index, int dflt) Gets the integer value at the given index, or the default if there is no value at this index. -
getLong
long getLong(int index) Gets the long value at the given index, or0
if there is no value at this index. NOTE: this is not accurate on the HTML backend as all numbers are represented as doubles, which cannot represent all possible long values. This is included for projects that use only the other backends and need long values. -
getLong
long getLong(int index, long dflt) Gets the long value at the given index, or the default if there is no value at this index. NOTE: this is not accurate on the HTML backend as all numbers are represented as doubles, which cannot represent all possible long values. This is included for projects that use only the other backends and need long values. -
getString
Gets the string value at the given index, ornull
if there is no value at this index. -
getString
Gets the string value at the given index, or the default if there is no value at this index. -
getObject
Gets the object value at the given index, ornull
if there is no value at this index. -
getObject
Gets the object value at the given index, or the default if there is no value at this index. -
getArray
Gets the array value at the given index, ornull
if there is no value at this index. -
getArray
Gets the array value at the given index, or the default if there is no value at this index. -
getArray
Gets an array at the given index that assumes its values are of the given json type, ornull
if there is no value at this index.- Parameters:
jsonType
- one of Json.Object, Json.Array, Boolean, Integer, Float, Double, or String- Throws:
IllegalArgumentException
- if jsonType is of an invalid type.
-
isArray
boolean isArray(int index) Returnstrue
if the value at the given index is an array. -
isBoolean
boolean isBoolean(int index) Returnstrue
if the value at the given index is a boolean. -
isNull
boolean isNull(int index) Returnstrue
if the value at the given index is null, or does not exist. -
isNumber
boolean isNumber(int index) Returnstrue
if the value at the given index is a number. -
isString
boolean isString(int index) Returnstrue
if the value at the given index is a string. -
isObject
boolean isObject(int index) Returnstrue
if the value at the given index is an object. -
add
Appends a JSON boolean, null, number, object, or array value.- Returns:
- a reference to this, allowing the calls to be chained together.
-
add
Inserts a JSON boolean, null, number, object, or array value at the given index. If the index is past the end of the array, the array is null-padded to the given index.- Returns:
- a reference to this, allowing the calls to be chained together.
-
remove
Removes a JSON value from the given index. If the index is out of bounds, this is a no-op.- Returns:
- a reference to this, allowing the calls to be chained together.
-
set
Sets a JSON boolean, null, number, object, or array value at the given index. If the index is past the end of the array, the array is null-padded to the given index.- Returns:
- a reference to this, allowing the calls to be chained together.
-
write
<T extends playn.core.json.JsonSink<T>> playn.core.json.JsonSink<T> write(playn.core.json.JsonSink<T> sink) Writes this object to aJsonSink
.
-