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 theJsonArrayto a plainList<Object>.Converts the JsonArray to aList<String>.getArrayFirstBigDecimal(int index) Gets the first element (as BigDecimal) of aJsonArrayelement.getArrayFirstBigDecimal(int index, BigDecimal defaultValue) Gets the first element (as BigDecimal) of aJsonArrayelement.getArrayFirstBoolean(int index) Gets the first element (as Boolean) of aJsonArrayelement.getArrayFirstBoolean(int index, Boolean defaultValue) Gets the first element (as Boolean) of aJsonArrayelement.byte[]getArrayFirstBytesFromBase64String(int index) Gets the first element (as byte[]) of aJsonArrayelement.byte[]getArrayFirstBytesFromBase64String(int index, byte[] defaultValue) Gets the first element (as byte[]) of aJsonArrayelement.getArrayFirstDate(int index) Gets the first element (as Date) of aJsonArrayelement.getArrayFirstDate(int index, Date defaultValue) Gets the first element (as Date) of aJsonArrayelement.getArrayFirstDouble(int index) Gets the first element (as Double) of aJsonArrayelement.getArrayFirstDouble(int index, Double defaultValue) Gets the first element (as Double) of aJsonArrayelement.getArrayFirstFloat(int index) Gets the first element (as Float) of aJsonArrayelement.getArrayFirstFloat(int index, Float defaultValue) Gets the first element (as Float) of aJsonArrayelement.getArrayFirstInstant(int index) Gets the first element (as Instant) of aJsonArrayelement.getArrayFirstInstant(int index, Instant defaultValue) Gets the first element (as Instant) of aJsonArrayelement.getArrayFirstInteger(int index) Gets the first element (as Integer) of aJsonArrayelement.getArrayFirstInteger(int index, Integer defaultValue) Gets the first element (as Integer) of aJsonArrayelement.getArrayFirstJsonArray(int index) Gets the first element (as JsonArray) of aJsonArrayelement.getArrayFirstJsonArray(int index, JsonArray defaultValue) Gets the first element (as JsonArray) of aJsonArrayelement.getArrayFirstJsonObject(int index) Gets the first element (as JsonObject) of aJsonArrayelement.getArrayFirstJsonObject(int index, JsonObject defaultValue) Gets the first element (as JsonObject) of aJsonArrayelement.getArrayFirstLong(int index) Gets the first element (as Long) of aJsonArrayelement.getArrayFirstLong(int index, Long defaultValue) Gets the first element (as Long) of aJsonArrayelement.getArrayFirstString(int index) Gets the first element (as String) of aJsonArrayelement.getArrayFirstString(int index, String defaultValue) Gets the first element (as String) of aJsonArrayelement.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 8601date element.Gets a UTC timezoned date from aISO 8601date 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 8601date element.getInstant(int index, Instant defaultValue) Gets an Instant from aISO 8601date 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.booleanisCanBeConvertedToBigDecimal(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeBigDecimal, or can be converted and retrieved as one.booleanisCanBeConvertedToBoolean(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeBoolean, or can be converted and retrieved as one.booleanisCanBeConvertedToByteArray(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typebase 64 Stringrepresenting a byte array, or can be converted and retrieved as one.booleanisCanBeConvertedToDate(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeDate, or can be converted and retrieved as one.booleanisCanBeConvertedToDouble(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeDouble, or can be converted and retrieved as one.booleanisCanBeConvertedToFloat(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeFloat, or can be converted and retrieved as one.booleanisCanBeConvertedToInteger(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeInteger, or can be converted and retrieved as one.booleanisCanBeConvertedToJsonArray(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeJsonArray, or can be converted and retrieved as one.booleanisCanBeConvertedToJsonObject(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeJsonObject, or can be converted and retrieved as one.booleanisCanBeConvertedToLong(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeLong, or can be converted and retrieved as one.booleanisCanBeConvertedToString(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeString, or can be converted and retrieved as one.booleanisElementExists(int index) Is there an element at the specified index? This returnstrueeven if the element isnull.booleanisEquivalentTo(JsonArray other) Compares the currentJsonArrayto the specified one and returnstrueif they are equivalent.booleanisNull(int index) Validates that there is an element at the specifiedindexand it isnull.booleanisOfTypeBigDecimal(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeBigDecimal, without requiring any conversion.booleanisOfTypeBoolean(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeBoolean, without requiring any conversion.booleanisOfTypeByteArray(int index, boolean acceptBase64StringToo) Validates that the element at the specifiedJsonPathexists and is currentlynullor of typebyte[], without requiring any conversion.booleanisOfTypeDate(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeDate, without requiring any conversion.booleanisOfTypeDouble(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeDouble, without requiring any conversion.booleanisOfTypeFloat(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeFloat, without requiring any conversion.booleanisOfTypeInteger(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeInteger, without requiring any conversion.booleanisOfTypeJsonArray(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeJsonArray, without requiring any conversion.booleanisOfTypeJsonObject(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeJsonObject, without requiring any conversion.booleanisOfTypeLong(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeLong, without requiring any conversion.booleanisOfTypeString(int index) Validates that the element at the specifiedindexexists and is currentlynullor 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.voidtransform(int index, ElementTransformer transformer) Transforms the element at the given index, using the specifiedElementTransformer.voidtrim(int index) Trims the element, if it's of typeString.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead 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,
nullelements are added to fill up positionss up to the specified index!Use
setinstead 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead of aJsonObject, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone- iftrue, and the element to add is aJsonObjectorJsonArray, 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 aJsonArrayis 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,
nullelements are added to fill positions up to the specified index!Use
setinstead 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead of aJsonObject, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone- iftrue, and the element to add is aJsonObjectorJsonArray, 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 aJsonArrayis 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead of aJsonObject, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone- iftrue, and the element to add is aJsonObjectorJsonArray, 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 aJsonArrayis 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead of aJsonObject, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone- iftrue, and the element to add is aJsonObjectorJsonArray, 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 aJsonArrayis 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead of aJsonObject, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone- iftrue, and the element to add is aJsonObjectorJsonArray, 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 aJsonArrayis 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,
nullelements are added to fill positions up to the specified index.Use
addinstead 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead 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,
nullelements are added to fill positions up to the specified index.Use
addinstead 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If the element implements
ToJsonObjectConvertible, it will be converted to aJsonObjectusing the associated conversion method. If it implementsToJsonArrayConvertible, it will be converted to anJsonArrayusing the associated conversion method.Those are the types of objects that will be converted to a
JsonArrayinstead of aJsonObject, if no conversion interface is implemented :- A Collection
- An array
- Parameters:
clone- iftrue, and the element to add is aJsonObjectorJsonArray, 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 aJsonArrayis 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 returnstrueeven if the element isnull.This is a synonym of
index >= 0 && index < size() -
getJsonObject
Gets an element asJsonObject.- Returns:
- the element or
nullif 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
defaultValueif 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
JsonObjectif 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
nullif 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
defaultValueif 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
JsonArrayif 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
nullif not found.
-
getString
Gets an element asString.- Returns:
- the element or the specified
defaultValueif not found.
-
getInteger
Gets an element asInteger.- Returns:
- the element or
nullif 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
defaultValueif 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
nullif 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
defaultValueif 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
nullif 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
defaultValueif 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
nullif 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
defaultValueif 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
nullif 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
defaultValueif 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
nullif 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
defaultValueif 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
nullif 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
defaultValueif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getDate
Gets a UTC timezoned date from aISO 8601date element.- Returns:
- the element or
nullif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getDate
Gets a UTC timezoned date from aISO 8601date element.- Returns:
- the element or the specified
defaultValueif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getInstant
Gets an Instant from aISO 8601date element.- Returns:
- the element or
nullif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getInstant
Gets an Instant from aISO 8601date element.- Returns:
- the element or the specified
defaultValueif 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
nullif 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
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 aJsonArrayelement.- Returns:
- the element or
nullif 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 aJsonArrayelement.- Returns:
- the element or the specified
defaultValueif 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 specifiedindexexists and is currentlynull, of typeString, or can be converted and retrieved as one. -
isCanBeConvertedToInteger
boolean isCanBeConvertedToInteger(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeInteger, or can be converted and retrieved as one. -
isCanBeConvertedToLong
boolean isCanBeConvertedToLong(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeLong, or can be converted and retrieved as one. -
isCanBeConvertedToFloat
boolean isCanBeConvertedToFloat(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeFloat, or can be converted and retrieved as one. -
isCanBeConvertedToDouble
boolean isCanBeConvertedToDouble(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeDouble, or can be converted and retrieved as one. -
isCanBeConvertedToBoolean
boolean isCanBeConvertedToBoolean(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeBoolean, or can be converted and retrieved as one. -
isCanBeConvertedToBigDecimal
boolean isCanBeConvertedToBigDecimal(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeBigDecimal, or can be converted and retrieved as one. -
isCanBeConvertedToByteArray
boolean isCanBeConvertedToByteArray(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typebase 64 Stringrepresenting a byte array, or can be converted and retrieved as one. -
isCanBeConvertedToDate
boolean isCanBeConvertedToDate(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeDate, or can be converted and retrieved as one. -
isCanBeConvertedToJsonObject
boolean isCanBeConvertedToJsonObject(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeJsonObject, or can be converted and retrieved as one. -
isCanBeConvertedToJsonArray
boolean isCanBeConvertedToJsonArray(int index) Validates that the element at the specifiedindexexists and is currentlynull, of typeJsonArray, or can be converted and retrieved as one. -
isOfTypeString
boolean isOfTypeString(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeString, without requiring any conversion. -
isOfTypeInteger
boolean isOfTypeInteger(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeInteger, without requiring any conversion. -
isOfTypeLong
boolean isOfTypeLong(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeLong, without requiring any conversion. -
isOfTypeFloat
boolean isOfTypeFloat(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeFloat, without requiring any conversion. -
isOfTypeDouble
boolean isOfTypeDouble(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeDouble, without requiring any conversion. -
isOfTypeBoolean
boolean isOfTypeBoolean(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeBoolean, without requiring any conversion. -
isOfTypeBigDecimal
boolean isOfTypeBigDecimal(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeBigDecimal, without requiring any conversion. -
isOfTypeByteArray
boolean isOfTypeByteArray(int index, boolean acceptBase64StringToo) Validates that the element at the specifiedJsonPathexists and is currentlynullor 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 specifiedindexexists and is currentlynullor of typeDate, without requiring any conversion. -
isOfTypeJsonObject
boolean isOfTypeJsonObject(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeJsonObject, without requiring any conversion. -
isOfTypeJsonArray
boolean isOfTypeJsonArray(int index) Validates that the element at the specifiedindexexists and is currentlynullor of typeJsonArray, without requiring any conversion. -
isNull
boolean isNull(int index) Validates that there is an element at the specifiedindexand it isnull. -
isEquivalentTo
Compares the currentJsonArrayto the specified one and returnstrueif 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
mutableparameter is set tofalse, then the current array will be returned as is since no cloning is then required.- Specified by:
clonein interfaceJsonObjectOrArray- Parameters:
mutable- iftruethe 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 theJsonArrayto a plainList<Object>. AllJsonObjectelements will be converted to Maps and allJsonArrayelements will be converted to Lists.This list is always a new instance and is mutable.
-