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> TConverts theJsonObjectto an instance of the specifiedTtype.Converts theJsonObjectto a plain Map.Gets the first value (as BigDecimal) of aJsonArrayelement .getArrayFirstBigDecimalNoKeyParsing(String key, BigDecimal defaultElement) Gets the first value (as BigDecimal) of aJsonArrayelement .Gets the first value (as Boolean) of aJsonArrayelement .getArrayFirstBooleanNoKeyParsing(String key, Boolean defaultElement) Gets the first value (as Boolean) of aJsonArrayelement .byte[]Gets the first value (as byte[]) of aJsonArrayelement .byte[]getArrayFirstBytesFromBase64StringNoKeyParsing(String key, byte[] defaultElement) Gets the first value (as byte[]) of aJsonArrayelement .Gets the first value (as Date) of aJsonArrayelement .getArrayFirstDateNoKeyParsing(String key, Date defaultElement) Gets the first value (as Date) of aJsonArrayelement.Gets the first value (as Double) of aJsonArrayelement .getArrayFirstDoubleNoKeyParsing(String key, Double defaultElement) Gets the first value (as Double) of aJsonArrayelement .Gets the first value (as Float) of aJsonArrayelement .getArrayFirstFloatNoKeyParsing(String key, Float defaultElement) Gets the first value (as Float) of aJsonArrayelement .Gets the first value (as Integer) of aJsonArrayelement .getArrayFirstIntegerNoKeyParsing(String key, Integer defaultElement) Gets the first value (as Integer) of aJsonArrayelement .Gets the first value (as JsonArray) of aJsonArrayelement .getArrayFirstJsonArrayNoKeyParsing(String key, JsonArray defaultElement) Gets the first value (as JsonArray) of aJsonArrayelement .Gets the first value (as JsonObject) of aJsonArrayelement .getArrayFirstJsonObjectNoKeyParsing(String key, JsonObject defaultElement) Gets the first value (as JsonObject) of aJsonArrayelement .Gets the first value (as Long) of aJsonArrayelement .getArrayFirstLongNoKeyParsing(String key, Long defaultElement) Gets the first value (as Long) of aJsonArrayelement .Gets the first value (as String) of aJsonArrayelement .getArrayFirstStringNoKeyParsing(String key, String defaultElement) Gets the first value (as String) of aJsonArrayelement .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 8601date element.getDateNoKeyParsing(String key, Date defaultElement) Gets a UTC timezoned date from aISO 8601date 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 8601date element.getInstantNoKeyParsing(String key, Instant defaultElement) Gets an Instant from aISO 8601date 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.booleanValidates 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.booleanValidates 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.booleanValidates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynull, of typebase 64 Stringrepresenting a byte array, or can be converted and retrieved as one.booleanValidates 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.booleanValidates 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.booleanValidates 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.booleanValidates that the element at the specifiedkey (not parsed as aJsonPath) exists and is currentlynull, of typeInteger, or can be converted and retrieved as one.booleanValidates 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.booleanValidates 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.booleanValidates 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.booleanValidates 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.booleanDoes the JsonObject contain an element at the specified key? The key is considered as is, without being parsed as aJsonPath.booleanisEquivalentTo(JsonObject other) Compares the currentJsonObjectto the specified one and returnstrueif they are equivalent.booleanisNullNoKeyParsing(String key) Validates that the element at the specified key (not parsed as aJsonPath) exists and isnull.booleanValidates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeBigDecimal, without requiring any conversion.booleanValidates that the element at the specified key (not parsed as aJsonPath)> exists and is currentlynullor of typeBoolean, without requiring any conversion.booleanisOfTypeByteArrayNoKeyParsing(String key, boolean acceptBase64StringToo) Validates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typebyte[], without requiring any conversion.booleanValidates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeDate, without requiring any conversion.booleanValidates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeDouble, without requiring any conversion.booleanValidates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeFloat, without requiring any conversion.booleanValidates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeInteger, without requiring any conversion.booleanValidates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeJsonArray, without requiring any conversion.booleanValidates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeJsonObject, without requiring any conversion.booleanValidates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeLong, without requiring any conversion.booleanValidates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor 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 specifiedJsonObjectproperties in the current object.merge(JsonObject jsonObj, boolean clone) Merges the specifiedJsonObjectproperties in the current object.merge(ToJsonObjectConvertible jsonObj) Transforms the specifie3d object toJsonObjectand 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, 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
-
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
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
-
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
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 aJsonObjectis 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
JsonObjectis 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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If an 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
-
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
JsonObjector aJsonArrayand is immutable, it will be cloned. Doing so, we can make sure theJsonArrayis always fully mutable or fully immutable.If an 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, a clone of anyJsonObjectorJsonArraywill 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 aJsonObjectis always fully mutable or fully immutable.
-
merge
Merges the specifiedJsonObjectproperties 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
JsonObjectis always fully mutable or fully immutable. -
merge
Merges the specifiedJsonObjectproperties in the current object. Overwrites elements of the same JsonPaths.- Parameters:
clone- iftrue, a clone of the originalJsonObjectwill 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 aJsonObjectis always fully mutable or fully immutable.
-
merge
Transforms the specifie3d object toJsonObjectand 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
nullif 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
defaultElementif 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
nullif 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
defaultElementif 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
JsonObjectif 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
nullif 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
defaultElementif 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
JsonArrayif 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
nullif not found.
-
getStringNoKeyParsing
Gets an element asString.- Returns:
- the element or the specified
defaultElementif not found.
-
getIntegerNoKeyParsing
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.
-
getIntegerNoKeyParsing
Gets an element asInteger.- Returns:
- the element or the specified
defaultElementif 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
nullif 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
defaultElementif 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
nullif 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
defaultElementif 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
nullif 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
defaultElementif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getBooleanNoKeyParsing
Gets an element asBoolean.The
keywill 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
nullif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getBooleanNoKeyParsing
Gets an element asBoolean.The
keywill be used as is, it won't be parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getBigDecimalNoKeyParsing
Gets an element asBigDecimal.The
keywill be used as is, it won't be parsed as aJsonPath.- Returns:
- the element or
nullif 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
keywill be used as is, it won't be parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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
keywill be used as is, it won't be parsed as aJsonPath.- Returns:
- the element or
nullif 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
keywill be used as is, it won't be parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getDateNoKeyParsing
Gets a UTC timezoned date from aISO 8601date element.The
keywill be used as is, it won't be parsed as aJsonPath.- Returns:
- the element or
nullif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getDateNoKeyParsing
Gets a UTC timezoned date from aISO 8601date element.The
keywill be used as is, it won't be parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getInstantNoKeyParsing
Gets an Instant from aISO 8601date element.The
keywill be used as is, it won't be parsed as aJsonPath.- Returns:
- the element or
nullif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getInstantNoKeyParsing
Gets an Instant from aISO 8601date element.The
keywill be used as is, it won't be parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif not found. - Throws:
CantConvertException- if an existing element can't be converted to the required type.
-
getArrayFirstJsonObjectNoKeyParsing
Gets the first value (as JsonObject) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- 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.
-
getArrayFirstJsonObjectNoKeyParsing
JsonObject getArrayFirstJsonObjectNoKeyParsing(String key, JsonObject defaultElement) throws CantConvertException Gets the first value (as JsonObject) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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 aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- 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.
-
getArrayFirstJsonArrayNoKeyParsing
JsonArray getArrayFirstJsonArrayNoKeyParsing(String key, JsonArray defaultElement) throws CantConvertException Gets the first value (as JsonArray) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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 aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or
nullif the array or the first element are not found.
-
getArrayFirstStringNoKeyParsing
Gets the first value (as String) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif the array or the first element are not found.
-
getArrayFirstIntegerNoKeyParsing
Gets the first value (as Integer) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- 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.
-
getArrayFirstIntegerNoKeyParsing
Integer getArrayFirstIntegerNoKeyParsing(String key, Integer defaultElement) throws CantConvertException Gets the first value (as Integer) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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 aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- 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.
-
getArrayFirstLongNoKeyParsing
Gets the first value (as Long) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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 aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- 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.
-
getArrayFirstDoubleNoKeyParsing
Double getArrayFirstDoubleNoKeyParsing(String key, Double defaultElement) throws CantConvertException Gets the first value (as Double) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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 aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- 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.
-
getArrayFirstFloatNoKeyParsing
Gets the first value (as Float) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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 aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- 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.
-
getArrayFirstBooleanNoKeyParsing
Boolean getArrayFirstBooleanNoKeyParsing(String key, Boolean defaultElement) throws CantConvertException Gets the first value (as Boolean) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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 aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- 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.
-
getArrayFirstBigDecimalNoKeyParsing
BigDecimal getArrayFirstBigDecimalNoKeyParsing(String key, BigDecimal defaultElement) throws CantConvertException Gets the first value (as BigDecimal) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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 aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- 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.
-
getArrayFirstBytesFromBase64StringNoKeyParsing
byte[] getArrayFirstBytesFromBase64StringNoKeyParsing(String key, byte[] defaultElement) throws CantConvertException Gets the first value (as byte[]) of aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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 aJsonArrayelement . The key will be used as is without being parsed as aJsonPath.- 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.
-
getArrayFirstDateNoKeyParsing
Gets the first value (as Date) of aJsonArrayelement. The key will be used as is without being parsed as aJsonPath.- Returns:
- the element or the specified
defaultElementif 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 theJsonObjectto an instance of the specifiedTtype.This uses
JsonManager#fromJsonStringand may throw an exception if it is unable to do the conversion. -
convertToPlainMap
Converts theJsonObjectto a plain Map. AllJsonObjectchildren will be converted to Maps and allJsonArraychildren 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 Stringrepresenting 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 currentlynullor of typeString, without requiring any conversion. -
isOfTypeIntegerNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeInteger, without requiring any conversion. -
isOfTypeLongNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeLong, without requiring any conversion. -
isOfTypeFloatNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeFloat, without requiring any conversion. -
isOfTypeDoubleNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeDouble, without requiring any conversion. -
isOfTypeBooleanNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath)> exists and is currentlynullor of typeBoolean, without requiring any conversion. -
isOfTypeBigDecimalNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeBigDecimal, without requiring any conversion. -
isOfTypeByteArrayNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor 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 currentlynullor of typeDate, without requiring any conversion. -
isOfTypeJsonObjectNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor of typeJsonObject, without requiring any conversion. -
isOfTypeJsonArrayNoKeyParsing
Validates that the element at the specified key (not parsed as aJsonPath) exists and is currentlynullor 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 currentJsonObjectto 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 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
mutableparameter is set tofalse, then the current object will be returned as is, since no cloning is required.- Specified by:
clonein interfaceJsonObjectOrArray- Parameters:
mutable- iftruethe resulting object and all its children will be mutable, otherwise they will all be immutable.
-