public.javadoc.org.spincast.core.json.JsonObject.html Maven / Gradle / Ivy
Show all versions of spincast-website Show documentation
JsonObject (org.spincast:spincast-framework 1.0.0 API)
org.spincast.core.json
Interface JsonObject
-
- All Superinterfaces:
- Iterable<Map.Entry<String,Object>>, JsonObjectOrArray
- All Known Subinterfaces:
- Form, SpincastXmlManager.JsonObjectMixIn
- All Known Implementing Classes:
- FormDefault, JsonObjectDefault, ValidationSetSimple
public interface JsonObject
extends JsonObjectOrArray, Iterable<Map.Entry<String,Object>>
Represents a Json
object, "{}".
-
-
Method Summary
All Methods Instance Methods Abstract Methods
Modifier and Type
Method and Description
JsonObject
clone(boolean mutable)
Deep copy of the JsonObject
, so any
modification to the original won't affect the
clone, and vice-versa.
<T> T
convert(Class<T> clazz)
Converts the JsonObject
to an instance of
the specified T
type.
Map<String,Object>
convertToPlainMap()
Converts the JsonObject
to a plain Map.
BigDecimal
getArrayFirstBigDecimalNoKeyParsing(String key)
Gets the first value (as BigDecimal) of a JsonArray
element
.
BigDecimal
getArrayFirstBigDecimalNoKeyParsing(String key,
BigDecimal defaultElement)
Gets the first value (as BigDecimal) of a JsonArray
element
.
Boolean
getArrayFirstBooleanNoKeyParsing(String key)
Gets the first value (as Boolean) of a JsonArray
element
.
Boolean
getArrayFirstBooleanNoKeyParsing(String key,
Boolean defaultElement)
Gets the first value (as Boolean) of a JsonArray
element
.
byte[]
getArrayFirstBytesFromBase64StringNoKeyParsing(String key)
Gets the first value (as byte[]) of a JsonArray
element
.
byte[]
getArrayFirstBytesFromBase64StringNoKeyParsing(String key,
byte[] defaultElement)
Gets the first value (as byte[]) of a JsonArray
element
.
Date
getArrayFirstDateNoKeyParsing(String key)
Gets the first value (as Date) of a JsonArray
element
.
Date
getArrayFirstDateNoKeyParsing(String key,
Date defaultElement)
Gets the first value (as Date) of a JsonArray
element.
Double
getArrayFirstDoubleNoKeyParsing(String key)
Gets the first value (as Double) of a JsonArray
element
.
Double
getArrayFirstDoubleNoKeyParsing(String key,
Double defaultElement)
Gets the first value (as Double) of a JsonArray
element
.
Float
getArrayFirstFloatNoKeyParsing(String key)
Gets the first value (as Float) of a JsonArray
element
.
Float
getArrayFirstFloatNoKeyParsing(String key,
Float defaultElement)
Gets the first value (as Float) of a JsonArray
element
.
Integer
getArrayFirstIntegerNoKeyParsing(String key)
Gets the first value (as Integer) of a JsonArray
element
.
Integer
getArrayFirstIntegerNoKeyParsing(String key,
Integer defaultElement)
Gets the first value (as Integer) of a JsonArray
element
.
JsonArray
getArrayFirstJsonArrayNoKeyParsing(String key)
Gets the first value (as JsonArray) of a JsonArray
element
.
JsonArray
getArrayFirstJsonArrayNoKeyParsing(String key,
JsonArray defaultElement)
Gets the first value (as JsonArray) of a JsonArray
element
.
JsonObject
getArrayFirstJsonObjectNoKeyParsing(String key)
Gets the first value (as JsonObject) of a JsonArray
element
.
JsonObject
getArrayFirstJsonObjectNoKeyParsing(String key,
JsonObject defaultElement)
Gets the first value (as JsonObject) of a JsonArray
element
.
Long
getArrayFirstLongNoKeyParsing(String key)
Gets the first value (as Long) of a JsonArray
element
.
Long
getArrayFirstLongNoKeyParsing(String key,
Long defaultElement)
Gets the first value (as Long) of a JsonArray
element
.
String
getArrayFirstStringNoKeyParsing(String key)
Gets the first value (as String) of a JsonArray
element
.
String
getArrayFirstStringNoKeyParsing(String key,
String defaultElement)
Gets the first value (as String) of a JsonArray
element
.
BigDecimal
getBigDecimalNoKeyParsing(String key)
Gets an element as BigDecimal
.
BigDecimal
getBigDecimalNoKeyParsing(String key,
BigDecimal defaultElement)
Gets an element as BigDecimal
.
Boolean
getBooleanNoKeyParsing(String key)
Gets an element as Boolean
.
Boolean
getBooleanNoKeyParsing(String key,
Boolean defaultElement)
Gets an element as Boolean
.
byte[]
getBytesFromBase64StringNoKeyParsing(String key)
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.
Date
getDateNoKeyParsing(String key)
Gets a UTC timezoned date from a ISO 8601
date element.
Date
getDateNoKeyParsing(String key,
Date defaultElement)
Gets a UTC timezoned date from a ISO 8601
date element.
Double
getDoubleNoKeyParsing(String jsonPath)
Gets an element as Double
.
Double
getDoubleNoKeyParsing(String jsonPath,
Double defaultElement)
Gets an element as Double
.
Float
getFloatNoKeyParsing(String jsonPath)
Gets an element as Float
.
Float
getFloatNoKeyParsing(String jsonPath,
Float defaultElement)
Gets an element as Float
.
Instant
getInstantNoKeyParsing(String key)
Gets an Instant from a ISO 8601
date element.
Instant
getInstantNoKeyParsing(String key,
Instant defaultElement)
Gets an Instant from a ISO 8601
date element.
Integer
getIntegerNoKeyParsing(String jsonPath)
Gets an element as Integer
.
Integer
getIntegerNoKeyParsing(String jsonPath,
Integer defaultElement)
Gets an element as Integer
.
JsonArray
getJsonArrayNoKeyParsing(String jsonPath)
Gets an element as JsonArray
.
JsonArray
getJsonArrayNoKeyParsing(String jsonPath,
JsonArray defaultElement)
Gets an element as JsonArray
.
JsonArray
getJsonArrayOrEmptyNoKeyParsing(String jsonPath)
Gets an element as JsonArray
.
JsonObject
getJsonObjectNoKeyParsing(String jsonPath)
Gets an element as JsonObject
.
JsonObject
getJsonObjectNoKeyParsing(String jsonPath,
JsonObject defaultElement)
Gets an element as JsonObject
.
JsonObject
getJsonObjectOrEmptyNoKeyParsing(String jsonPath)
Gets an element as JsonObject
.
Long
getLongNoKeyParsing(String jsonPath)
Gets an element as Long
.
Long
getLongNoKeyParsing(String jsonPath,
Long defaultElement)
Gets an element as Long
.
Object
getObjectNoKeyParsing(String jsonPath)
Gets an untyped Object.
Object
getObjectNoKeyParsing(String jsonPath,
Object defaultElement)
Gets an untyped Object.
String
getStringNoKeyParsing(String jsonPath)
Gets an element as String
.
String
getStringNoKeyParsing(String jsonPath,
String defaultElement)
Gets an element as String
.
boolean
isCanBeConvertedToBigDecimalNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type BigDecimal
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToBooleanNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type Boolean
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToByteArrayNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type base 64 String
representing
a byte array, or can be converted and retrieved as one.
boolean
isCanBeConvertedToDateNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type Date
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToDoubleNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type Double
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToFloatNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type Float
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToIntegerNoKeyParsing(String key)
Validates that the element at the specifiedkey (not parsed
as a JsonPath
) exists and
is currently null
, of type Integer
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToJsonArrayNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type JsonArray
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToJsonObjectNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type JsonObject
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToLongNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type Long
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToStringNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type String
, or can be
converted and retrieved as one.
boolean
isElementExistsNoKeyParsing(String key)
Does the JsonObject contain an element at
the specified key?
The key is considered as is, without
being parsed as a JsonPath
.
boolean
isEquivalentTo(JsonObject other)
Compares the current JsonObject
to the specified one
and returns true
if they are equivalent.
boolean
isNullNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is null
.
boolean
isOfTypeBigDecimalNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type BigDecimal
, without requiring
any conversion.
boolean
isOfTypeBooleanNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
)> exists and
is currently null
or of type Boolean
, without requiring
any conversion.
boolean
isOfTypeByteArrayNoKeyParsing(String key,
boolean acceptBase64StringToo)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type byte[]
, without requiring
any conversion.
boolean
isOfTypeDateNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type Date
, without requiring
any conversion.
boolean
isOfTypeDoubleNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type Double
, without requiring
any conversion.
boolean
isOfTypeFloatNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type Float
, without requiring
any conversion.
boolean
isOfTypeIntegerNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type Integer
, without requiring
any conversion.
boolean
isOfTypeJsonArrayNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type JsonArray
, without requiring
any conversion.
boolean
isOfTypeJsonObjectNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type JsonObject
, without requiring
any conversion.
boolean
isOfTypeLongNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type Long
, without requiring
any conversion.
boolean
isOfTypeStringNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type String
, without requiring
any conversion.
JsonObject
merge(JsonObject jsonObj)
Merges the specified JsonObject
properties in the current
object.
JsonObject
merge(JsonObject jsonObj,
boolean clone)
Merges the specified JsonObject
properties in the current
object.
JsonObject
merge(Map<String,?> map)
Merges all the specified Map elements in the JsonObject.
JsonObject
merge(Map<String,?> map,
boolean clone)
Merges all the specified Map elements in the JsonObject.
JsonObject
merge(ToJsonObjectConvertible jsonObj)
Transforms the specifie3d object to JsonObject
and merges its properties in the current
object.
JsonObject
removeNoKeyParsing(String key)
Removes a element from the object.
JsonObject
setNoKeyParsing(String key,
Object element)
Sets an element at the specified key, without parsing this
key as a JsonPath
.
JsonObject
setNoKeyParsing(String key,
Object element,
boolean clone)
Sets an element at the specified key, without parsing this
key as a JsonPath
.
-
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, remove, set, set, size, toJsonString, toJsonString, transform, transformAll, transformAll, trim, trimAll, trimAll
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
Method Detail
-
setNoKeyParsing
JsonObject setNoKeyParsing(String key,
Object element)
Sets an element at the specified key, without parsing this
key as a JsonPath
.
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
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
is always
fully mutable or fully immutable.
If the element implements ToJsonObjectConvertible
, it
will be converted to a JsonObject
using the associated
conversion method. If it implements ToJsonArrayConvertible
, it
will be converted to an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
-
setNoKeyParsing
JsonObject setNoKeyParsing(String key,
Object element,
boolean clone)
Sets an element at the specified key, without parsing this
key as a JsonPath
.
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
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
is always
fully mutable or fully immutable.
If the element implements ToJsonObjectConvertible
, it
will be converted to a JsonObject
using the associated
conversion method. If it implements ToJsonArrayConvertible
, it
will be converted to an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
- Parameters:
clone
- if true
, and the element to add is a
JsonObject
or JsonArray
, 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 a
JsonObject
is always
fully mutable or fully immutable.
-
merge
JsonObject merge(Map<String,?> map)
Merges all the specified Map elements in the JsonObject. The keys
are parsed as JsonPaths
.
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
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
is always
fully mutable or fully immutable.
If an element implements ToJsonObjectConvertible
, it
will be converted to a JsonObject
using the associated
conversion method. If it implements ToJsonArrayConvertible
, it
will be converted to an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
-
merge
JsonObject merge(Map<String,?> map,
boolean clone)
Merges all the specified Map elements in the JsonObject. The keys
are parsed as JsonPaths
.
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
a JsonArray
and is immutable, it will be cloned.
Doing so, we can make sure the JsonArray
is always
fully mutable or fully immutable.
If an element implements ToJsonObjectConvertible
, it
will be converted to a JsonObject
using the associated
conversion method. If it implements ToJsonArrayConvertible
, it
will be converted to an JsonArray
using the associated
conversion method.
Those are the types of objects that will be converted to a
JsonArray
instead of a JsonObject
, if
no conversion interface is implemented :
-
A Collection
-
An array
- Parameters:
clone
- if true
, a clone of any
JsonObject
or JsonArray
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 a
JsonObject
is always
fully mutable or fully immutable.
-
merge
JsonObject merge(JsonObject jsonObj)
Merges the specified JsonObject
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
JsonObject merge(JsonObject jsonObj,
boolean clone)
Merges the specified JsonObject
properties in the current
object. Overwrites elements of the same JsonPaths.
- Parameters:
clone
- if true
, a clone of the original
JsonObject
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 a
JsonObject
is always
fully mutable or fully immutable.
-
merge
JsonObject merge(ToJsonObjectConvertible jsonObj)
Transforms the specifie3d object to JsonObject
and merges its properties in the current
object. Overwrites elements of the same JsonPaths.
-
removeNoKeyParsing
JsonObject removeNoKeyParsing(String key)
Removes a element from the object.
The key is used as is, without
being parsed as a JsonPath
.
-
isElementExistsNoKeyParsing
boolean isElementExistsNoKeyParsing(String key)
Does the JsonObject contain an element at
the specified key?
The key is considered as is, without
being parsed as a JsonPath
.
-
getObjectNoKeyParsing
Object getObjectNoKeyParsing(String jsonPath)
Gets an untyped Object.
- Returns:
- the object or
null
if not found. This object
will inevitably be of a type managed by JsonObject
, since
an object of any other type is automatically converted when added.
-
getObjectNoKeyParsing
Object getObjectNoKeyParsing(String jsonPath,
Object defaultElement)
Gets an untyped Object.
- Returns:
- the object or the specified
defaultElement
if not found. This object
will inevitably be of a type managed by JsonObject
, since
an object of any other type is automatically converted when added.
-
getJsonObjectNoKeyParsing
JsonObject getJsonObjectNoKeyParsing(String jsonPath)
throws CantConvertException
Gets an element as JsonObject
.
- 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 as JsonObject
.
- 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
JsonObject getJsonObjectOrEmptyNoKeyParsing(String jsonPath)
throws CantConvertException
Gets an element as JsonObject
.
- Returns:
- the element or an empty
JsonObject
if not found or if null
.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getJsonArrayNoKeyParsing
JsonArray getJsonArrayNoKeyParsing(String jsonPath)
throws CantConvertException
Gets an element as JsonArray
.
- 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 as JsonArray
.
- 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
JsonArray getJsonArrayOrEmptyNoKeyParsing(String jsonPath)
throws CantConvertException
Gets an element as JsonArray
.
- Returns:
- the element or an empty
JsonArray
if not found or if null
.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getStringNoKeyParsing
String getStringNoKeyParsing(String jsonPath)
Gets an element as String
.
- Returns:
- the element or
null
if not found.
-
getStringNoKeyParsing
String getStringNoKeyParsing(String jsonPath,
String defaultElement)
Gets an element as String
.
- Returns:
- the element or the specified
defaultElement
if not found.
-
getIntegerNoKeyParsing
Integer getIntegerNoKeyParsing(String jsonPath)
throws CantConvertException
Gets an element as Integer
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getIntegerNoKeyParsing
Integer getIntegerNoKeyParsing(String jsonPath,
Integer defaultElement)
throws CantConvertException
Gets an element as Integer
.
- 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
Long getLongNoKeyParsing(String jsonPath)
throws CantConvertException
Gets an element as Long
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getLongNoKeyParsing
Long getLongNoKeyParsing(String jsonPath,
Long defaultElement)
throws CantConvertException
Gets an element as Long
.
- 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
Float getFloatNoKeyParsing(String jsonPath)
throws CantConvertException
Gets an element as Float
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getFloatNoKeyParsing
Float getFloatNoKeyParsing(String jsonPath,
Float defaultElement)
throws CantConvertException
Gets an element as Float
.
- 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
Double getDoubleNoKeyParsing(String jsonPath)
throws CantConvertException
Gets an element as Double
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getDoubleNoKeyParsing
Double getDoubleNoKeyParsing(String jsonPath,
Double defaultElement)
throws CantConvertException
Gets an element as Double
.
- 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
Boolean getBooleanNoKeyParsing(String key)
throws CantConvertException
Gets an element as Boolean
.
The key
will be used as is, it won't be parsed
as a JsonPath
.
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
Boolean getBooleanNoKeyParsing(String key,
Boolean defaultElement)
throws CantConvertException
Gets an element as Boolean
.
The key
will be used as is, it won't be parsed
as a JsonPath
.
- 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
BigDecimal getBigDecimalNoKeyParsing(String key)
throws CantConvertException
Gets an element as BigDecimal
.
The key
will be used as is, it won't be parsed
as a JsonPath
.
- 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 as BigDecimal
.
The key
will be used as is, it won't be parsed
as a JsonPath
.
- 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
byte[] getBytesFromBase64StringNoKeyParsing(String key)
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 a JsonPath
.
- 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 a JsonPath
.
- 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
Date getDateNoKeyParsing(String key)
throws CantConvertException
Gets a UTC timezoned date from a ISO 8601
date element.
The key
will be used as is, it won't be parsed
as a JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getDateNoKeyParsing
Date getDateNoKeyParsing(String key,
Date defaultElement)
throws CantConvertException
Gets a UTC timezoned date from a ISO 8601
date element.
The key
will be used as is, it won't be parsed
as a JsonPath
.
- 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
Instant getInstantNoKeyParsing(String key)
throws CantConvertException
Gets an Instant from a ISO 8601
date element.
The key
will be used as is, it won't be parsed
as a JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getInstantNoKeyParsing
Instant getInstantNoKeyParsing(String key,
Instant defaultElement)
throws CantConvertException
Gets an Instant from a ISO 8601
date element.
The key
will be used as is, it won't be parsed
as a JsonPath
.
- 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
JsonObject getArrayFirstJsonObjectNoKeyParsing(String key)
throws CantConvertException
Gets the first value (as JsonObject) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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 a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
JsonArray getArrayFirstJsonArrayNoKeyParsing(String key)
throws CantConvertException
Gets the first value (as JsonArray) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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 a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
String getArrayFirstStringNoKeyParsing(String key)
Gets the first value (as String) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- Returns:
- the element or
null
if the array or
the first element are not found.
-
getArrayFirstStringNoKeyParsing
String getArrayFirstStringNoKeyParsing(String key,
String defaultElement)
Gets the first value (as String) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- Returns:
- the element or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstIntegerNoKeyParsing
Integer getArrayFirstIntegerNoKeyParsing(String key)
throws CantConvertException
Gets the first value (as Integer) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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 a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
Long getArrayFirstLongNoKeyParsing(String key)
throws CantConvertException
Gets the first value (as Long) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
Long getArrayFirstLongNoKeyParsing(String key,
Long defaultElement)
throws CantConvertException
Gets the first value (as Long) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
Double getArrayFirstDoubleNoKeyParsing(String key)
throws CantConvertException
Gets the first value (as Double) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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 a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
Float getArrayFirstFloatNoKeyParsing(String key)
throws CantConvertException
Gets the first value (as Float) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
Float getArrayFirstFloatNoKeyParsing(String key,
Float defaultElement)
throws CantConvertException
Gets the first value (as Float) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
Boolean getArrayFirstBooleanNoKeyParsing(String key)
throws CantConvertException
Gets the first value (as Boolean) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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 a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
BigDecimal getArrayFirstBigDecimalNoKeyParsing(String key)
throws CantConvertException
Gets the first value (as BigDecimal) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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 a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
byte[] getArrayFirstBytesFromBase64StringNoKeyParsing(String key)
throws CantConvertException
Gets the first value (as byte[]) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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 a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
Date getArrayFirstDateNoKeyParsing(String key)
throws CantConvertException
Gets the first value (as Date) of a JsonArray
element
. The key will be used as is without being parsed
as a JsonPath
.
- 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
Date getArrayFirstDateNoKeyParsing(String key,
Date defaultElement)
throws CantConvertException
Gets the first value (as Date) of a JsonArray
element.
The key will be used as is without being parsed
as a JsonPath
.
- 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
<T> T convert(Class<T> clazz)
Converts the JsonObject
to an instance of
the specified T
type.
This uses JsonManager#fromJsonString
and may throw an exception if it is unable to do the conversion.
-
convertToPlainMap
Map<String,Object> convertToPlainMap()
Converts the JsonObject
to a plain Map.
All JsonObject
children will be converted to
Maps and all JsonArray
children will be converted to
Lists.
-
isCanBeConvertedToStringNoKeyParsing
boolean isCanBeConvertedToStringNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type String
, or can be
converted and retrieved as one.
-
isCanBeConvertedToIntegerNoKeyParsing
boolean isCanBeConvertedToIntegerNoKeyParsing(String key)
Validates that the element at the specifiedkey (not parsed
as a JsonPath
) exists and
is currently null
, of type Integer
, or can be
converted and retrieved as one.
-
isCanBeConvertedToLongNoKeyParsing
boolean isCanBeConvertedToLongNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type Long
, or can be
converted and retrieved as one.
-
isCanBeConvertedToFloatNoKeyParsing
boolean isCanBeConvertedToFloatNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type Float
, or can be
converted and retrieved as one.
-
isCanBeConvertedToDoubleNoKeyParsing
boolean isCanBeConvertedToDoubleNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type Double
, or can be
converted and retrieved as one.
-
isCanBeConvertedToBooleanNoKeyParsing
boolean isCanBeConvertedToBooleanNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type Boolean
, or can be
converted and retrieved as one.
-
isCanBeConvertedToBigDecimalNoKeyParsing
boolean isCanBeConvertedToBigDecimalNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type BigDecimal
, or can be
converted and retrieved as one.
-
isCanBeConvertedToByteArrayNoKeyParsing
boolean isCanBeConvertedToByteArrayNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type base 64 String
representing
a byte array, or can be converted and retrieved as one.
-
isCanBeConvertedToDateNoKeyParsing
boolean isCanBeConvertedToDateNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type Date
, or can be
converted and retrieved as one.
-
isCanBeConvertedToJsonObjectNoKeyParsing
boolean isCanBeConvertedToJsonObjectNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type JsonObject
, or can be
converted and retrieved as one.
-
isCanBeConvertedToJsonArrayNoKeyParsing
boolean isCanBeConvertedToJsonArrayNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
, of type JsonArray
, or can be
converted and retrieved as one.
-
isOfTypeStringNoKeyParsing
boolean isOfTypeStringNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type String
, without requiring
any conversion.
-
isOfTypeIntegerNoKeyParsing
boolean isOfTypeIntegerNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type Integer
, without requiring
any conversion.
-
isOfTypeLongNoKeyParsing
boolean isOfTypeLongNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type Long
, without requiring
any conversion.
-
isOfTypeFloatNoKeyParsing
boolean isOfTypeFloatNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type Float
, without requiring
any conversion.
-
isOfTypeDoubleNoKeyParsing
boolean isOfTypeDoubleNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type Double
, without requiring
any conversion.
-
isOfTypeBooleanNoKeyParsing
boolean isOfTypeBooleanNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
)> exists and
is currently null
or of type Boolean
, without requiring
any conversion.
-
isOfTypeBigDecimalNoKeyParsing
boolean isOfTypeBigDecimalNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type BigDecimal
, without requiring
any conversion.
-
isOfTypeByteArrayNoKeyParsing
boolean isOfTypeByteArrayNoKeyParsing(String key,
boolean acceptBase64StringToo)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type byte[]
, without requiring
any conversion.
- Parameters:
acceptBase64StringToo
- if true
, then a valid base 64 String
will also be accepted.
-
isOfTypeDateNoKeyParsing
boolean isOfTypeDateNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type Date
, without requiring
any conversion.
-
isOfTypeJsonObjectNoKeyParsing
boolean isOfTypeJsonObjectNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type JsonObject
, without requiring
any conversion.
-
isOfTypeJsonArrayNoKeyParsing
boolean isOfTypeJsonArrayNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is currently null
or of type JsonArray
, without requiring
any conversion.
-
isNullNoKeyParsing
boolean isNullNoKeyParsing(String key)
Validates that the element at the specified key (not parsed
as a JsonPath
) exists and
is null
.
-
isEquivalentTo
boolean isEquivalentTo(JsonObject other)
Compares the current JsonObject
to the specified one
and returns true
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 to
new BigDecimal("123")
or to 123L
.
-
clone
JsonObject clone(boolean mutable)
Deep copy of the JsonObject
, 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 to false
,
then the current object will be returned as is, since no
cloning is required.
- Specified by:
clone
in interface JsonObjectOrArray
- Parameters:
mutable
- if true
the resulting
object and all its children will be mutable, otherwise
they will all be immutable.
Copyright © 2019. All rights reserved.