Interface JsonArray
- All Superinterfaces:
Iterable<Object>
,JsonObjectOrArray
- All Known Subinterfaces:
SpincastXmlManager.JsonArrayMixIn
- All Known Implementing Classes:
JsonArrayDefault
Json
array, "[]".-
Method Summary
Modifier and TypeMethodDescriptionInserts an object at the specified index in the array.Adds an object at the specified index.Adds an object at the end of the array.Adds an object at the end of the array.Adds all elements at the end of the array.Adds elements at the end of the array.addAll
(Collection<?> values) Adds all elements at the end of the array.addAll
(Collection<?> values, boolean clone) Adds all elements at the end of the array.Adds all elements at the end of the array.Adds elements at the end of the array.clone
(boolean mutable) Deep copy of theJsonArray
, so any modification to the original won't affect the clone, and vice-versa.Converts theJsonArray
to a plainList<Object>
.Converts the JsonArray to aList<String>
.getArrayFirstBigDecimal
(int index) Gets the first element (as BigDecimal) of aJsonArray
element.getArrayFirstBigDecimal
(int index, BigDecimal defaultValue) Gets the first element (as BigDecimal) of aJsonArray
element.getArrayFirstBoolean
(int index) Gets the first element (as Boolean) of aJsonArray
element.getArrayFirstBoolean
(int index, Boolean defaultValue) Gets the first element (as Boolean) of aJsonArray
element.byte[]
getArrayFirstBytesFromBase64String
(int index) Gets the first element (as byte[]) of aJsonArray
element.byte[]
getArrayFirstBytesFromBase64String
(int index, byte[] defaultValue) Gets the first element (as byte[]) of aJsonArray
element.getArrayFirstDate
(int index) Gets the first element (as Date) of aJsonArray
element.getArrayFirstDate
(int index, Date defaultValue) Gets the first element (as Date) of aJsonArray
element.getArrayFirstDouble
(int index) Gets the first element (as Double) of aJsonArray
element.getArrayFirstDouble
(int index, Double defaultValue) Gets the first element (as Double) of aJsonArray
element.getArrayFirstFloat
(int index) Gets the first element (as Float) of aJsonArray
element.getArrayFirstFloat
(int index, Float defaultValue) Gets the first element (as Float) of aJsonArray
element.getArrayFirstInstant
(int index) Gets the first element (as Instant) of aJsonArray
element.getArrayFirstInstant
(int index, Instant defaultValue) Gets the first element (as Instant) of aJsonArray
element.getArrayFirstInteger
(int index) Gets the first element (as Integer) of aJsonArray
element.getArrayFirstInteger
(int index, Integer defaultValue) Gets the first element (as Integer) of aJsonArray
element.getArrayFirstJsonArray
(int index) Gets the first element (as JsonArray) of aJsonArray
element.getArrayFirstJsonArray
(int index, JsonArray defaultValue) Gets the first element (as JsonArray) of aJsonArray
element.getArrayFirstJsonObject
(int index) Gets the first element (as JsonObject) of aJsonArray
element.getArrayFirstJsonObject
(int index, JsonObject defaultValue) Gets the first element (as JsonObject) of aJsonArray
element.getArrayFirstLong
(int index) Gets the first element (as Long) of aJsonArray
element.getArrayFirstLong
(int index, Long defaultValue) Gets the first element (as Long) of aJsonArray
element.getArrayFirstString
(int index) Gets the first element (as String) of aJsonArray
element.getArrayFirstString
(int index, String defaultValue) Gets the first element (as String) of aJsonArray
element.getBigDecimal
(int index) Gets an element asBigDecimal
.getBigDecimal
(int index, BigDecimal defaultValue) Gets an element asBigDecimal
.getBoolean
(int index) Gets an element asBoolean
.getBoolean
(int index, Boolean defaultValue) Gets an element asBoolean
.byte[]
getBytesFromBase64String
(int index) Gets a byte array, from a base 64 encoded element.byte[]
getBytesFromBase64String
(int index, byte[] defaultValue) Gets a byte array, from a base 64 encoded element.getDate
(int index) Gets a UTC timezoned date from aISO 8601
date element.Gets a UTC timezoned date from aISO 8601
date element.getDouble
(int index) Gets an element asDouble
.Gets an element asDouble
.getFloat
(int index) Gets an element asFloat
.Gets an element asFloat
.getInstant
(int index) Gets an Instant from aISO 8601
date element.getInstant
(int index, Instant defaultValue) Gets an Instant from aISO 8601
date element.getInteger
(int index) Gets an element asInteger
.getInteger
(int index, Integer defaultValue) Gets an element asInteger
.getJsonArray
(int index) Gets an element asJsonArray
.getJsonArray
(int index, JsonArray defaultValue) Gets an element asJsonArray
.getJsonArrayOrEmpty
(int index) Gets an element asJsonArray
.getJsonObject
(int index) Gets an element asJsonObject
.getJsonObject
(int index, JsonObject defaultValue) Gets an element asJsonObject
.getJsonObjectOrEmpty
(int index) Gets an element asJsonObject
.getLong
(int index) Gets an element asLong
.Gets an element asLong
.getObject
(int index) Gets an element, untyped.Gets an element, untyped.getString
(int index) Gets an element asString
.Gets an element asString
.boolean
isCanBeConvertedToBigDecimal
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeBigDecimal
, or can be converted and retrieved as one.boolean
isCanBeConvertedToBoolean
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeBoolean
, or can be converted and retrieved as one.boolean
isCanBeConvertedToByteArray
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typebase 64 String
representing a byte array, or can be converted and retrieved as one.boolean
isCanBeConvertedToDate
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeDate
, or can be converted and retrieved as one.boolean
isCanBeConvertedToDouble
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeDouble
, or can be converted and retrieved as one.boolean
isCanBeConvertedToFloat
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeFloat
, or can be converted and retrieved as one.boolean
isCanBeConvertedToInteger
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeInteger
, or can be converted and retrieved as one.boolean
isCanBeConvertedToJsonArray
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeJsonArray
, or can be converted and retrieved as one.boolean
isCanBeConvertedToJsonObject
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeJsonObject
, or can be converted and retrieved as one.boolean
isCanBeConvertedToLong
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeLong
, or can be converted and retrieved as one.boolean
isCanBeConvertedToString
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeString
, or can be converted and retrieved as one.boolean
isElementExists
(int index) Is there an element at the specified index? This returnstrue
even if the element isnull
.boolean
isEquivalentTo
(JsonArray other) Compares the currentJsonArray
to the specified one and returnstrue
if they are equivalent.boolean
isNull
(int index) Validates that there is an element at the specifiedindex
and it isnull
.boolean
isOfTypeBigDecimal
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeBigDecimal
, without requiring any conversion.boolean
isOfTypeBoolean
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeBoolean
, without requiring any conversion.boolean
isOfTypeByteArray
(int index, boolean acceptBase64StringToo) Validates that the element at the specifiedJsonPath
exists and is currentlynull
or of typebyte[]
, without requiring any conversion.boolean
isOfTypeDate
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeDate
, without requiring any conversion.boolean
isOfTypeDouble
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeDouble
, without requiring any conversion.boolean
isOfTypeFloat
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeFloat
, without requiring any conversion.boolean
isOfTypeInteger
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeInteger
, without requiring any conversion.boolean
isOfTypeJsonArray
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeJsonArray
, without requiring any conversion.boolean
isOfTypeJsonObject
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeJsonObject
, without requiring any conversion.boolean
isOfTypeLong
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeLong
, without requiring any conversion.boolean
isOfTypeString
(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeString
, without requiring any conversion.remove
(int index) Removes an element at the specified index.Sets an object at the specified index.Sets an object at the specified index.void
transform
(int index, ElementTransformer transformer) Transforms the element at the given index, using the specifiedElementTransformer
.void
trim
(int index) Trims the element, if it's of typeString
.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.spincast.core.json.JsonObjectOrArray
clear, contains, getArrayFirstBigDecimal, getArrayFirstBigDecimal, getArrayFirstBoolean, getArrayFirstBoolean, getArrayFirstBytesFromBase64String, getArrayFirstBytesFromBase64String, getArrayFirstDate, getArrayFirstDate, getArrayFirstDouble, getArrayFirstDouble, getArrayFirstFloat, getArrayFirstFloat, getArrayFirstInstant, getArrayFirstInstant, getArrayFirstInteger, getArrayFirstInteger, getArrayFirstJsonArray, getArrayFirstJsonArray, getArrayFirstJsonObject, getArrayFirstJsonObject, getArrayFirstLong, getArrayFirstLong, getArrayFirstString, getArrayFirstString, getBigDecimal, getBigDecimal, getBoolean, getBoolean, getBytesFromBase64String, getBytesFromBase64String, getDate, getDate, getDouble, getDouble, getFloat, getFloat, getInstant, getInstant, getInteger, getInteger, getJsonArray, getJsonArray, getJsonArrayOrEmpty, getJsonArrayOrEmpty, getJsonObject, getJsonObject, getJsonObjectOrEmpty, getJsonObjectOrEmpty, getLong, getLong, getObject, getObject, getString, getString, isCanBeConvertedToBigDecimal, isCanBeConvertedToBoolean, isCanBeConvertedToByteArray, isCanBeConvertedToDate, isCanBeConvertedToDouble, isCanBeConvertedToFloat, isCanBeConvertedToInteger, isCanBeConvertedToJsonArray, isCanBeConvertedToJsonObject, isCanBeConvertedToLong, isCanBeConvertedToString, isMutable, isNull, isOfTypeBigDecimal, isOfTypeBoolean, isOfTypeByteArray, isOfTypeDate, isOfTypeDouble, isOfTypeFloat, isOfTypeInteger, isOfTypeJsonArray, isOfTypeJsonObject, isOfTypeLong, isOfTypeString, isPresent, remove, set, set, setIfAbsent, setIfAbsent, size, toJsonString, toJsonString, transform, transformAll, transformAll, trim, trimAll, trimAll
-
Method Details
-
add
Adds an object at the end of the array.If the object to add is not of a native type, then the object is converted before being added. Once the object is converted and added, a modification of the original object won't affect this element, and vice-versa.
If the element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
-
add
Inserts an object at the specified index in the array. Any existing elements starting at this index are pushed to the right.If the specified index is greater than the current end of the array,
null
elements are added to fill up positionss up to the specified index!Use
set
instead if you want to replace the element at the specified index.If the object to add is not of a native type, then the object is converted before being added. Once the object is converted and added, a modification of the original object won't affect this element, and vice-versa.
If the element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
-
add
Adds an object at the end of the array.If the object to add is not of a native type, then the object is converted before being added. Once the object is converted and added, a modification of the original object won't affect this element, and vice-versa.
If the element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone
- iftrue
, and the element to add is aJsonObject
orJsonArray
, a clone will be made before being added. If that case, any modification to the original element won't affect the added one, and vice-versa. If the element is immutable then it will always be cloned. Doing so, we can make sure aJsonArray
is always fully mutable or fully immutable.
-
add
Adds an object at the specified index.Any existing elements starting at this index are pushed to the right.
If the specified index is greater than the current end of the array,
null
elements are added to fill positions up to the specified index!Use
set
instead if you want to replace the element at the specified index.If the object to add is not of a native type, then the object is converted before being added. Once the object is converted and added, a modification of the original object won't affect this element, and vice-versa.
If the element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone
- iftrue
, and the element to add is aJsonObject
orJsonArray
, a clone will be made before being added. If that case, any modification to the original element won't affect the added one, and vice-versa. If the element is immutable then it will always be cloned. Doing so, we can make sure aJsonArray
is always fully mutable or fully immutable.
-
addAll
Adds all elements at the end of the array.If an element to add is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.
If an element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
-
addAll
Adds all elements at the end of the array.If an element to add is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.
If an element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone
- iftrue
, and the element to add is aJsonObject
orJsonArray
, a clone will be made before being added. If that case, any modification to the original element won't affect the added one, and vice-versa. If the element is immutable then it will always be cloned. Doing so, we can make sure aJsonArray
is always fully mutable or fully immutable.
-
addAll
Adds all elements at the end of the array.If an element to add is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.
If an element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
-
addAll
Adds elements at the end of the array.If an element to add is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.
If an element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone
- iftrue
, and the element to add is aJsonObject
orJsonArray
, a clone will be made before being added. If that case, any modification to the original element won't affect the added one, and vice-versa. If the element is immutable then it will always be cloned. Doing so, we can make sure aJsonArray
is always fully mutable or fully immutable.
-
addAll
Adds all elements at the end of the array.If an element to add is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.
If an element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
-
addAll
Adds elements at the end of the array.If an element to add is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.
If an element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone
- iftrue
, and the element to add is aJsonObject
orJsonArray
, a clone will be made before being added. If that case, any modification to the original element won't affect the added one, and vice-versa. If the element is immutable then it will always be cloned. Doing so, we can make sure aJsonArray
is always fully mutable or fully immutable.
-
set
Sets an object at the specified index. If there is an element at this index, it is overwritten.If the specified index is greater than the current end of the array,
null
elements are added to fill positions up to the specified index.Use
add
instead if you want to insert the element at the specified index without overwritting any existing element.If an element to add is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.
If an element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
-
set
Sets an object at the specified index. If there is an element at this index, it is overwritten.If the specified index is greater than the current end of the array,
null
elements are added to fill positions up to the specified index.Use
add
instead if you want to insert the element at the specified index without overwritting any existing element.If an element to add is not of a native type, then the element is converted before being added. Once the element is converted and added, a modification of the original object won't affect this element, and vice-versa.
If an element to add is a
JsonObject
or aJsonArray
and is immutable, it will be cloned. Doing so, we can make sure theJsonArray
is always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible
, it will be converted to aJsonObject
using the associated conversion method. If it implementsToJsonArrayConvertible
, it will be converted to anJsonArray
using the associated conversion method.Those are the types of objects that will be converted to a
JsonArray
instead of aJsonObject
, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone
- iftrue
, and the element to add is aJsonObject
orJsonArray
, a clone will be made before being added. If that case, any modification to the original element won't affect the added one, and vice-versa. If the element is immutable then it will always be cloned. Doing so, we can make sure aJsonArray
is always fully mutable or fully immutable.
-
remove
Removes an element at the specified index. Any elements to the right are shift to the left. If the index is invalid, nothing is done. -
isElementExists
boolean isElementExists(int index) Is there an element at the specified index? This returnstrue
even if the element isnull
.This is a synonym of
index >= 0 && index < size()
-
getJsonObject
Gets an element asJsonObject
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getJsonObject
Gets an element asJsonObject
.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getJsonObjectOrEmpty
Gets an element asJsonObject
.- Returns:
- the element or an empty
JsonObject
if not found or ifnull
. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getJsonArray
Gets an element asJsonArray
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getJsonArray
Gets an element asJsonArray
.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getJsonArrayOrEmpty
Gets an element asJsonArray
.- Returns:
- the element or an empty
JsonArray
if not found or ifnull
. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getString
Gets an element asString
.- Returns:
- the element or
null
if not found.
-
getString
Gets an element asString
.- Returns:
- the element or the specified
defaultValue
if not found.
-
getInteger
Gets an element asInteger
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getInteger
Gets an element asInteger
.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getLong
Gets an element asLong
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getLong
Gets an element asLong
.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getFloat
Gets an element asFloat
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getFloat
Gets an element asFloat
.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getDouble
Gets an element asDouble
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getDouble
Gets an element asDouble
.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBoolean
Gets an element asBoolean
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBoolean
Gets an element asBoolean
.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBigDecimal
Gets an element asBigDecimal
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBigDecimal
Gets an element asBigDecimal
.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBytesFromBase64String
Gets a byte array, from a base 64 encoded element.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBytesFromBase64String
Gets a byte array, from a base 64 encoded element.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getDate
Gets a UTC timezoned date from aISO 8601
date element.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getDate
Gets a UTC timezoned date from aISO 8601
date element.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getInstant
Gets an Instant from aISO 8601
date element.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getInstant
Gets an Instant from aISO 8601
date element.- Returns:
- the element or the specified
defaultValue
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getObject
Gets an element, untyped.- Returns:
- the object or
null
if not found. This object will necessarly be of a type managed byJsonArray
, since an object of any other type is automatically converted when added.
-
getObject
Gets an element, untyped.- Returns:
- the object or the specified
defaultValue
if not found. This object will necessarly be of a type managed byJsonArray
, since an object of any other type is automatically converted when added.
-
getArrayFirstJsonObject
Gets the first element (as JsonObject) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstJsonObject
Gets the first element (as JsonObject) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstJsonArray
Gets the first element (as JsonArray) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstJsonArray
Gets the first element (as JsonArray) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstString
Gets the first element (as String) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstString
Gets the first element (as String) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstInteger
Gets the first element (as Integer) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstInteger
Gets the first element (as Integer) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstLong
Gets the first element (as Long) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstLong
Gets the first element (as Long) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstDouble
Gets the first element (as Double) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstDouble
Gets the first element (as Double) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstFloat
Gets the first element (as Float) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstFloat
Gets the first element (as Float) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstBoolean
Gets the first element (as Boolean) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstBoolean
Gets the first element (as Boolean) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstBigDecimal
Gets the first element (as BigDecimal) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstBigDecimal
Gets the first element (as BigDecimal) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstBytesFromBase64String
Gets the first element (as byte[]) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstBytesFromBase64String
byte[] getArrayFirstBytesFromBase64String(int index, byte[] defaultValue) throws CantConvertException Gets the first element (as byte[]) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstDate
Gets the first element (as Date) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstDate
Gets the first element (as Date) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstInstant
Gets the first element (as Instant) of aJsonArray
element.- Returns:
- the element or
null
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstInstant
Gets the first element (as Instant) of aJsonArray
element.- Returns:
- the element or the specified
defaultValue
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
isCanBeConvertedToString
boolean isCanBeConvertedToString(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeString
, or can be converted and retrieved as one. -
isCanBeConvertedToInteger
boolean isCanBeConvertedToInteger(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeInteger
, or can be converted and retrieved as one. -
isCanBeConvertedToLong
boolean isCanBeConvertedToLong(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeLong
, or can be converted and retrieved as one. -
isCanBeConvertedToFloat
boolean isCanBeConvertedToFloat(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeFloat
, or can be converted and retrieved as one. -
isCanBeConvertedToDouble
boolean isCanBeConvertedToDouble(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeDouble
, or can be converted and retrieved as one. -
isCanBeConvertedToBoolean
boolean isCanBeConvertedToBoolean(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeBoolean
, or can be converted and retrieved as one. -
isCanBeConvertedToBigDecimal
boolean isCanBeConvertedToBigDecimal(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeBigDecimal
, or can be converted and retrieved as one. -
isCanBeConvertedToByteArray
boolean isCanBeConvertedToByteArray(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typebase 64 String
representing a byte array, or can be converted and retrieved as one. -
isCanBeConvertedToDate
boolean isCanBeConvertedToDate(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeDate
, or can be converted and retrieved as one. -
isCanBeConvertedToJsonObject
boolean isCanBeConvertedToJsonObject(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeJsonObject
, or can be converted and retrieved as one. -
isCanBeConvertedToJsonArray
boolean isCanBeConvertedToJsonArray(int index) Validates that the element at the specifiedindex
exists and is currentlynull
, of typeJsonArray
, or can be converted and retrieved as one. -
isOfTypeString
boolean isOfTypeString(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeString
, without requiring any conversion. -
isOfTypeInteger
boolean isOfTypeInteger(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeInteger
, without requiring any conversion. -
isOfTypeLong
boolean isOfTypeLong(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeLong
, without requiring any conversion. -
isOfTypeFloat
boolean isOfTypeFloat(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeFloat
, without requiring any conversion. -
isOfTypeDouble
boolean isOfTypeDouble(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeDouble
, without requiring any conversion. -
isOfTypeBoolean
boolean isOfTypeBoolean(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeBoolean
, without requiring any conversion. -
isOfTypeBigDecimal
boolean isOfTypeBigDecimal(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeBigDecimal
, without requiring any conversion. -
isOfTypeByteArray
boolean isOfTypeByteArray(int index, boolean acceptBase64StringToo) Validates that the element at the specifiedJsonPath
exists and is currentlynull
or of typebyte[]
, without requiring any conversion.- Parameters:
acceptBase64StringToo
- iftrue
, then a valid base 64 String will also be accepted.
-
isOfTypeDate
boolean isOfTypeDate(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeDate
, without requiring any conversion. -
isOfTypeJsonObject
boolean isOfTypeJsonObject(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeJsonObject
, without requiring any conversion. -
isOfTypeJsonArray
boolean isOfTypeJsonArray(int index) Validates that the element at the specifiedindex
exists and is currentlynull
or of typeJsonArray
, without requiring any conversion. -
isNull
boolean isNull(int index) Validates that there is an element at the specifiedindex
and it isnull
. -
isEquivalentTo
Compares the currentJsonArray
to the specified one and returnstrue
if they are equivalent. To be equivalent, all their elements must be so too.An element is equivalent to the other if they can be converted to the¸ same type, and then if they are equals.
For example, the
String
"123" is equivalent tonew BigDecimal("123")
or to123L
. -
clone
Deep copy of theJsonArray
, so any modification to the original won't affect the clone, and vice-versa.Note that if the current array is immutable and the
mutable
parameter is set tofalse
, then the current array will be returned as is since no cloning is then required.- Specified by:
clone
in interfaceJsonObjectOrArray
- Parameters:
mutable
- iftrue
the resulting array and all its children will be mutable, otherwise they will all be immutable.
-
transform
Transforms the element at the given index, using the specifiedElementTransformer
. -
trim
void trim(int index) Trims the element, if it's of typeString
. -
convertToStringList
Converts the JsonArray to aList<String>
. To do so, thetoString()
method will be called on any non null element.This list is always a new instance and is mutable.
-
convertToPlainList
Converts theJsonArray
to a plainList<Object>
. AllJsonObject
elements will be converted to Maps and allJsonArray
elements will be converted to Lists.This list is always a new instance and is mutable.
-