Interface JsonObject
- All Superinterfaces:
Iterable<Map.Entry<String,
,Object>> JsonObjectOrArray
- All Known Subinterfaces:
Form
,SpincastXmlManager.JsonObjectMixIn
- All Known Implementing Classes:
FormDefault
,JsonObjectDefault
,ValidationSetSimple
Json
object, "{}".-
Method Summary
Modifier and TypeMethodDescriptionclone
(boolean mutable) Deep copy of theJsonObject
, so any modification to the original won't affect the clone, and vice-versa.<T> T
Converts theJsonObject
to an instance of the specifiedT
type.Converts theJsonObject
to a plain Map.Gets the first value (as BigDecimal) of aJsonArray
element .getArrayFirstBigDecimalNoKeyParsing
(String key, BigDecimal defaultElement) Gets the first value (as BigDecimal) of aJsonArray
element .Gets the first value (as Boolean) of aJsonArray
element .getArrayFirstBooleanNoKeyParsing
(String key, Boolean defaultElement) Gets the first value (as Boolean) of aJsonArray
element .byte[]
Gets the first value (as byte[]) of aJsonArray
element .byte[]
getArrayFirstBytesFromBase64StringNoKeyParsing
(String key, byte[] defaultElement) Gets the first value (as byte[]) of aJsonArray
element .Gets the first value (as Date) of aJsonArray
element .getArrayFirstDateNoKeyParsing
(String key, Date defaultElement) Gets the first value (as Date) of aJsonArray
element.Gets the first value (as Double) of aJsonArray
element .getArrayFirstDoubleNoKeyParsing
(String key, Double defaultElement) Gets the first value (as Double) of aJsonArray
element .Gets the first value (as Float) of aJsonArray
element .getArrayFirstFloatNoKeyParsing
(String key, Float defaultElement) Gets the first value (as Float) of aJsonArray
element .Gets the first value (as Integer) of aJsonArray
element .getArrayFirstIntegerNoKeyParsing
(String key, Integer defaultElement) Gets the first value (as Integer) of aJsonArray
element .Gets the first value (as JsonArray) of aJsonArray
element .getArrayFirstJsonArrayNoKeyParsing
(String key, JsonArray defaultElement) Gets the first value (as JsonArray) of aJsonArray
element .Gets the first value (as JsonObject) of aJsonArray
element .getArrayFirstJsonObjectNoKeyParsing
(String key, JsonObject defaultElement) Gets the first value (as JsonObject) of aJsonArray
element .Gets the first value (as Long) of aJsonArray
element .getArrayFirstLongNoKeyParsing
(String key, Long defaultElement) Gets the first value (as Long) of aJsonArray
element .Gets the first value (as String) of aJsonArray
element .getArrayFirstStringNoKeyParsing
(String key, String defaultElement) Gets the first value (as String) of aJsonArray
element .Gets an element asBigDecimal
.getBigDecimalNoKeyParsing
(String key, BigDecimal defaultElement) Gets an element asBigDecimal
.Gets an element asBoolean
.getBooleanNoKeyParsing
(String key, Boolean defaultElement) Gets an element asBoolean
.byte[]
Gets a byte array, from a base 64 encoded element.byte[]
getBytesFromBase64StringNoKeyParsing
(String key, byte[] defaultElement) Gets a byte array, from a base 64 encoded element.Gets a UTC timezoned date from aISO 8601
date element.getDateNoKeyParsing
(String key, Date defaultElement) Gets a UTC timezoned date from aISO 8601
date element.getDoubleNoKeyParsing
(String jsonPath) Gets an element asDouble
.getDoubleNoKeyParsing
(String jsonPath, Double defaultElement) Gets an element asDouble
.getFloatNoKeyParsing
(String jsonPath) Gets an element asFloat
.getFloatNoKeyParsing
(String jsonPath, Float defaultElement) Gets an element asFloat
.Gets an Instant from aISO 8601
date element.getInstantNoKeyParsing
(String key, Instant defaultElement) Gets an Instant from aISO 8601
date element.getIntegerNoKeyParsing
(String jsonPath) Gets an element asInteger
.getIntegerNoKeyParsing
(String jsonPath, Integer defaultElement) Gets an element asInteger
.getJsonArrayNoKeyParsing
(String jsonPath) Gets an element asJsonArray
.getJsonArrayNoKeyParsing
(String jsonPath, JsonArray defaultElement) Gets an element asJsonArray
.getJsonArrayOrEmptyNoKeyParsing
(String jsonPath) Gets an element asJsonArray
.getJsonObjectNoKeyParsing
(String jsonPath) Gets an element asJsonObject
.getJsonObjectNoKeyParsing
(String jsonPath, JsonObject defaultElement) Gets an element asJsonObject
.getJsonObjectOrEmptyNoKeyParsing
(String jsonPath) Gets an element asJsonObject
.getLongNoKeyParsing
(String jsonPath) Gets an element asLong
.getLongNoKeyParsing
(String jsonPath, Long defaultElement) Gets an element asLong
.getObjectNoKeyParsing
(String jsonPath) Gets an untyped Object.getObjectNoKeyParsing
(String jsonPath, Object defaultElement) Gets an untyped Object.getStringNoKeyParsing
(String jsonPath) Gets an element asString
.getStringNoKeyParsing
(String jsonPath, String defaultElement) Gets an element asString
.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeBigDecimal
, or can be converted and retrieved as one.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeBoolean
, or can be converted and retrieved as one.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typebase 64 String
representing a byte array, or can be converted and retrieved as one.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeDate
, or can be converted and retrieved as one.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeDouble
, or can be converted and retrieved as one.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeFloat
, or can be converted and retrieved as one.boolean
Validates that the element at the specifiedkey (not parsed as aJsonPath
) exists and is currentlynull
, of typeInteger
, or can be converted and retrieved as one.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeJsonArray
, or can be converted and retrieved as one.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeJsonObject
, or can be converted and retrieved as one.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeLong
, or can be converted and retrieved as one.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeString
, or can be converted and retrieved as one.boolean
Does the JsonObject contain an element at the specified key? The key is considered as is, without being parsed as aJsonPath
.boolean
isEquivalentTo
(JsonObject other) Compares the currentJsonObject
to the specified one and returnstrue
if they are equivalent.boolean
isNullNoKeyParsing
(String key) Validates that the element at the specified key (not parsed as aJsonPath
) exists and isnull
.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeBigDecimal
, without requiring any conversion.boolean
Validates that the element at the specified key (not parsed as aJsonPath
)> exists and is currentlynull
or of typeBoolean
, without requiring any conversion.boolean
isOfTypeByteArrayNoKeyParsing
(String key, boolean acceptBase64StringToo) Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typebyte[]
, without requiring any conversion.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeDate
, without requiring any conversion.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeDouble
, without requiring any conversion.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeFloat
, without requiring any conversion.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeInteger
, without requiring any conversion.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeJsonArray
, without requiring any conversion.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeJsonObject
, without requiring any conversion.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeLong
, without requiring any conversion.boolean
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeString
, without requiring any conversion.Merges all the specified Map elements in the JsonObject.Merges all the specified Map elements in the JsonObject.merge
(JsonObject jsonObj) Merges the specifiedJsonObject
properties in the current object.merge
(JsonObject jsonObj, boolean clone) Merges the specifiedJsonObject
properties in the current object.merge
(ToJsonObjectConvertible jsonObj) Transforms the specifie3d object toJsonObject
and merges its properties in the current object.removeNoKeyParsing
(String key) Removes a element from the object.setNoKeyParsing
(String key, Object element) Sets an element at the specified key, without parsing this key as aJsonPath
.setNoKeyParsing
(String key, Object element, boolean clone) Sets an element at the specified key, without parsing this key as aJsonPath
.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
-
setNoKeyParsing
Sets an element at the specified key, without parsing this key as aJsonPath
.If the 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 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
-
setNoKeyParsing
Sets an element at the specified key, without parsing this key as aJsonPath
.If the 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 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 aJsonObject
is always fully mutable or fully immutable.
-
merge
Merges all the specified Map elements in the JsonObject. The keys are parsed asJsonPaths
. Overwrites existing elements at the specified JsonPaths.Note that the JsonObject and JsonArray objects from the source will be added as is, so any modification to them WILL affect the added elements, and vise-versa. There is an exception though : if the element to add is immutable then it will always be cloned. Doing so, we can make sure a
JsonObject
is always fully mutable or fully immutable.If an element to 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 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 an 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
-
merge
Merges all the specified Map elements in the JsonObject. The keys are parsed asJsonPaths
. Overwrites existing elements at the specified JsonPaths.If an element to 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 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 an 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
, a clone of anyJsonObject
orJsonArray
will be made before being added. If that case, any modification to the original elements won't affect the added elements, and vice-versa. If the element is immutable then it will always be cloned. Doing so, we can make sure aJsonObject
is always fully mutable or fully immutable.
-
merge
Merges the specifiedJsonObject
properties in the current object. Overwrites elements of the same JsonPaths.Note that the elements from the source are added as is, so any modification to them WILL affect the added element, and vise-versa. There is an exception though : if an element to add is immutable then it will always be cloned. Doing so, we can make sure a
JsonObject
is always fully mutable or fully immutable. -
merge
Merges the specifiedJsonObject
properties in the current object. Overwrites elements of the same JsonPaths.- Parameters:
clone
- iftrue
, a clone of the originalJsonObject
will be made before being added. If that case, any modification to the original object won't affect the added element, and vice-versa. If an element is immutable then it will always be cloned. Doing so, we can make sure aJsonObject
is always fully mutable or fully immutable.
-
merge
Transforms the specifie3d object toJsonObject
and merges its properties in the current object. Overwrites elements of the same JsonPaths. -
removeNoKeyParsing
Removes a element from the object. The key is used as is, without being parsed as aJsonPath
. -
isElementExistsNoKeyParsing
Does the JsonObject contain an element at the specified key? The key is considered as is, without being parsed as aJsonPath
. -
getObjectNoKeyParsing
Gets an untyped Object.- Returns:
- the object or
null
if not found. This object will inevitably be of a type managed byJsonObject
, since an object of any other type is automatically converted when added.
-
getObjectNoKeyParsing
Gets an untyped Object.- Returns:
- the object or the specified
defaultElement
if not found. This object will inevitably be of a type managed byJsonObject
, since an object of any other type is automatically converted when added.
-
getJsonObjectNoKeyParsing
Gets an element asJsonObject
.- Returns:
- the object or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getJsonObjectNoKeyParsing
JsonObject getJsonObjectNoKeyParsing(String jsonPath, JsonObject defaultElement) throws CantConvertException Gets an element asJsonObject
.- Returns:
- the object or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getJsonObjectOrEmptyNoKeyParsing
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.
-
getJsonArrayNoKeyParsing
Gets an element asJsonArray
.- Returns:
- the object or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getJsonArrayNoKeyParsing
JsonArray getJsonArrayNoKeyParsing(String jsonPath, JsonArray defaultElement) throws CantConvertException Gets an element asJsonArray
.- Returns:
- the object or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getJsonArrayOrEmptyNoKeyParsing
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.
-
getStringNoKeyParsing
Gets an element asString
.- Returns:
- the element or
null
if not found.
-
getStringNoKeyParsing
Gets an element asString
.- Returns:
- the element or the specified
defaultElement
if not found.
-
getIntegerNoKeyParsing
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.
-
getIntegerNoKeyParsing
Gets an element asInteger
.- Returns:
- the element or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getLongNoKeyParsing
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.
-
getLongNoKeyParsing
Gets an element asLong
.- Returns:
- the element or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getFloatNoKeyParsing
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.
-
getFloatNoKeyParsing
Gets an element asFloat
.- Returns:
- the element or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getDoubleNoKeyParsing
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.
-
getDoubleNoKeyParsing
Gets an element asDouble
.- Returns:
- the element or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBooleanNoKeyParsing
Gets an element asBoolean
.The
key
will be used as is, it won't be parsed as aJsonPath
.The signature of this method is different than from the other "get" methods with a "parseJsonPath" parameter since we have to differenciate it from the overload that takes a Boolean default value.
- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBooleanNoKeyParsing
Gets an element asBoolean
.The
key
will be used as is, it won't be parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBigDecimalNoKeyParsing
Gets an element asBigDecimal
.The
key
will be used as is, it won't be parsed as aJsonPath
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBigDecimalNoKeyParsing
BigDecimal getBigDecimalNoKeyParsing(String key, BigDecimal defaultElement) throws CantConvertException Gets an element asBigDecimal
.The
key
will be used as is, it won't be parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBytesFromBase64StringNoKeyParsing
Gets a byte array, from a base 64 encoded element.The
key
will be used as is, it won't be parsed as aJsonPath
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getBytesFromBase64StringNoKeyParsing
byte[] getBytesFromBase64StringNoKeyParsing(String key, byte[] defaultElement) throws CantConvertException Gets a byte array, from a base 64 encoded element.The
key
will be used as is, it won't be parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getDateNoKeyParsing
Gets a UTC timezoned date from aISO 8601
date element.The
key
will be used as is, it won't be parsed as aJsonPath
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getDateNoKeyParsing
Gets a UTC timezoned date from aISO 8601
date element.The
key
will be used as is, it won't be parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getInstantNoKeyParsing
Gets an Instant from aISO 8601
date element.The
key
will be used as is, it won't be parsed as aJsonPath
.- Returns:
- the element or
null
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getInstantNoKeyParsing
Gets an Instant from aISO 8601
date element.The
key
will be used as is, it won't be parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstJsonObjectNoKeyParsing
Gets the first value (as JsonObject) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- 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.
-
getArrayFirstJsonObjectNoKeyParsing
JsonObject getArrayFirstJsonObjectNoKeyParsing(String key, JsonObject defaultElement) throws CantConvertException Gets the first value (as JsonObject) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstJsonArrayNoKeyParsing
Gets the first value (as JsonArray) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- 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.
-
getArrayFirstJsonArrayNoKeyParsing
JsonArray getArrayFirstJsonArrayNoKeyParsing(String key, JsonArray defaultElement) throws CantConvertException Gets the first value (as JsonArray) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstStringNoKeyParsing
Gets the first value (as String) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or
null
if the array or the first element are not found.
-
getArrayFirstStringNoKeyParsing
Gets the first value (as String) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the array or the first element are not found.
-
getArrayFirstIntegerNoKeyParsing
Gets the first value (as Integer) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- 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.
-
getArrayFirstIntegerNoKeyParsing
Integer getArrayFirstIntegerNoKeyParsing(String key, Integer defaultElement) throws CantConvertException Gets the first value (as Integer) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the arr ay or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstLongNoKeyParsing
Gets the first value (as Long) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- 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.
-
getArrayFirstLongNoKeyParsing
Gets the first value (as Long) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstDoubleNoKeyParsing
Gets the first value (as Double) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- 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.
-
getArrayFirstDoubleNoKeyParsing
Double getArrayFirstDoubleNoKeyParsing(String key, Double defaultElement) throws CantConvertException Gets the first value (as Double) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstFloatNoKeyParsing
Gets the first value (as Float) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- 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.
-
getArrayFirstFloatNoKeyParsing
Gets the first value (as Float) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstBooleanNoKeyParsing
Gets the first value (as Boolean) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- 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.
-
getArrayFirstBooleanNoKeyParsing
Boolean getArrayFirstBooleanNoKeyParsing(String key, Boolean defaultElement) throws CantConvertException Gets the first value (as Boolean) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstBigDecimalNoKeyParsing
Gets the first value (as BigDecimal) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- 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.
-
getArrayFirstBigDecimalNoKeyParsing
BigDecimal getArrayFirstBigDecimalNoKeyParsing(String key, BigDecimal defaultElement) throws CantConvertException Gets the first value (as BigDecimal) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstBytesFromBase64StringNoKeyParsing
Gets the first value (as byte[]) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- 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.
-
getArrayFirstBytesFromBase64StringNoKeyParsing
byte[] getArrayFirstBytesFromBase64StringNoKeyParsing(String key, byte[] defaultElement) throws CantConvertException Gets the first value (as byte[]) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
getArrayFirstDateNoKeyParsing
Gets the first value (as Date) of aJsonArray
element . The key will be used as is without being parsed as aJsonPath
.- 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.
-
getArrayFirstDateNoKeyParsing
Gets the first value (as Date) of aJsonArray
element. The key will be used as is without being parsed as aJsonPath
.- Returns:
- the element or the specified
defaultElement
if the array or the first element are not found. - Throws:
CantConvertException
- if an existing element can't be converted to the required type.
-
convert
Converts theJsonObject
to an instance of the specifiedT
type.This uses
JsonManager#fromJsonString
and may throw an exception if it is unable to do the conversion. -
convertToPlainMap
Converts theJsonObject
to a plain Map. AllJsonObject
children will be converted to Maps and allJsonArray
children will be converted to Lists. -
isCanBeConvertedToStringNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeString
, or can be converted and retrieved as one. -
isCanBeConvertedToIntegerNoKeyParsing
Validates that the element at the specifiedkey (not parsed as aJsonPath
) exists and is currentlynull
, of typeInteger
, or can be converted and retrieved as one. -
isCanBeConvertedToLongNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeLong
, or can be converted and retrieved as one. -
isCanBeConvertedToFloatNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeFloat
, or can be converted and retrieved as one. -
isCanBeConvertedToDoubleNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeDouble
, or can be converted and retrieved as one. -
isCanBeConvertedToBooleanNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeBoolean
, or can be converted and retrieved as one. -
isCanBeConvertedToBigDecimalNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeBigDecimal
, or can be converted and retrieved as one. -
isCanBeConvertedToByteArrayNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typebase 64 String
representing a byte array, or can be converted and retrieved as one. -
isCanBeConvertedToDateNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeDate
, or can be converted and retrieved as one. -
isCanBeConvertedToJsonObjectNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeJsonObject
, or can be converted and retrieved as one. -
isCanBeConvertedToJsonArrayNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
, of typeJsonArray
, or can be converted and retrieved as one. -
isOfTypeStringNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeString
, without requiring any conversion. -
isOfTypeIntegerNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeInteger
, without requiring any conversion. -
isOfTypeLongNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeLong
, without requiring any conversion. -
isOfTypeFloatNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeFloat
, without requiring any conversion. -
isOfTypeDoubleNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeDouble
, without requiring any conversion. -
isOfTypeBooleanNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
)> exists and is currentlynull
or of typeBoolean
, without requiring any conversion. -
isOfTypeBigDecimalNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeBigDecimal
, without requiring any conversion. -
isOfTypeByteArrayNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typebyte[]
, without requiring any conversion.- Parameters:
acceptBase64StringToo
- iftrue
, then a valid base 64 String will also be accepted.
-
isOfTypeDateNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeDate
, without requiring any conversion. -
isOfTypeJsonObjectNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeJsonObject
, without requiring any conversion. -
isOfTypeJsonArrayNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and is currentlynull
or of typeJsonArray
, without requiring any conversion. -
isNullNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath
) exists and isnull
. -
isEquivalentTo
Compares the currentJsonObject
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 theJsonObject
, so any modification to the original won't affect the clone, and vice-versa.Note that if the current object is immutable and the
mutable
parameter is set tofalse
, then the current object will be returned as is, since no cloning is required.- Specified by:
clone
in interfaceJsonObjectOrArray
- Parameters:
mutable
- iftrue
the resulting object and all its children will be mutable, otherwise they will all be immutable.
-