public.javadoc.org.spincast.core.json.JsonObjectOrArray.html Maven / Gradle / Ivy
Show all versions of spincast-website Show documentation
JsonObjectOrArray (org.spincast:spincast-framework 1.0.0 API)
org.spincast.core.json
Interface JsonObjectOrArray
-
- All Known Subinterfaces:
- Form, JsonArray, JsonObject, SpincastXmlManager.JsonArrayMixIn, SpincastXmlManager.JsonObjectMixIn
- All Known Implementing Classes:
- FormDefault, JsonArrayDefault, JsonObjectArrayBase, JsonObjectDefault, ValidationSetSimple
public interface JsonObjectOrArray
Base interface for JsonObject
and
JsonArray
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods
Modifier and Type
Method and Description
JsonObjectOrArray
clear()
Clears all elements.
JsonObjectOrArray
clone(boolean mutable)
Clone the object.
boolean
contains(String jsonPath)
Does the object contain an element at
the JsonPath
position (even if
null
)?
BigDecimal
getArrayFirstBigDecimal(String jsonPath)
Gets the first value (as BigDecimal) of a JsonArray
property
of the object, using the JsonPath
to find the array.
BigDecimal
getArrayFirstBigDecimal(String jsonPath,
BigDecimal defaultElement)
Gets the first value (as BigDecimal) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Boolean
getArrayFirstBoolean(String jsonPath)
Gets the first value (as Boolean) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Boolean
getArrayFirstBoolean(String jsonPath,
Boolean defaultElement)
Gets the first value (as Boolean) of a JsonArray
property
of the object, using the JsonPath
to find the array.
byte[]
getArrayFirstBytesFromBase64String(String jsonPath)
Gets the first value (as byte[]) of a JsonArray
property
of the object, using the JsonPath
to find the array.
byte[]
getArrayFirstBytesFromBase64String(String jsonPath,
byte[] defaultElement)
Gets the first value (as byte[]) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Date
getArrayFirstDate(String jsonPath)
Gets the first value (as Date) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Date
getArrayFirstDate(String jsonPath,
Date defaultElement)
Gets the first value (as Date) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Double
getArrayFirstDouble(String jsonPath)
Gets the first value (as Double) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Double
getArrayFirstDouble(String jsonPath,
Double defaultElement)
Gets the first value (as Double) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Float
getArrayFirstFloat(String jsonPath)
Gets the first value (as Float) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Float
getArrayFirstFloat(String jsonPath,
Float defaultElement)
Gets the first value (as Float) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Instant
getArrayFirstInstant(String jsonPath)
Gets the first value (as Instant) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Instant
getArrayFirstInstant(String jsonPath,
Instant defaultElement)
Gets the first value (as Instant) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Integer
getArrayFirstInteger(String jsonPath)
Gets the first value (as Integer) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Integer
getArrayFirstInteger(String jsonPath,
Integer defaultElement)
Gets the first value (as Integer) of a JsonArray
property
of the object, using the JsonPath
to find the array.
JsonArray
getArrayFirstJsonArray(String jsonPath)
Gets the first value (as JsonArray) of a JsonArray
property
of the object, using the JsonPath
to find the array.
JsonArray
getArrayFirstJsonArray(String jsonPath,
JsonArray defaultElement)
Gets the first value (as JsonArray) of a JsonArray
property
of the object, using the JsonPath
to find the array.
JsonObject
getArrayFirstJsonObject(String jsonPath)
Gets the first value (as JsonObject) of a JsonArray
property
of the object, using the JsonPath
to find the array.
JsonObject
getArrayFirstJsonObject(String jsonPath,
JsonObject defaultElement)
Gets the first value (as JsonObject) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Long
getArrayFirstLong(String jsonPath)
Gets the first value (as Long) of a JsonArray
property
of the object, using the JsonPath
to find the array.
Long
getArrayFirstLong(String jsonPath,
Long defaultElement)
Gets the first value (as Long) of a JsonArray
property
of the object, using the JsonPath
to find the array.
String
getArrayFirstString(String jsonPath)
Gets the first value (as String) of a JsonArray
property
of the object, using the JsonPath
to find the array.
String
getArrayFirstString(String jsonPath,
String defaultElement)
Gets the first value (as String) of a JsonArray
property
of the object, using the JsonPath
to find the array.
BigDecimal
getBigDecimal(String jsonPath)
Gets an element as BigDecimal
using the
specified JsonPath
.
BigDecimal
getBigDecimal(String jsonPath,
BigDecimal defaultElement)
Gets an element as BigDecimal
using the
specified JsonPath
.
Boolean
getBoolean(String jsonPath)
Gets an element as Boolean
using the
specified JsonPath
.
Boolean
getBoolean(String jsonPath,
Boolean defaultElement)
Gets an element as Boolean
using the
specified JsonPath
.
byte[]
getBytesFromBase64String(String jsonPath)
Gets a byte array, from a base 64 encoded element using the
specified JsonPath
.
byte[]
getBytesFromBase64String(String jsonPath,
byte[] defaultElement)
Gets a byte array, from a base 64 encoded element using the
specified JsonPath
.
Date
getDate(String jsonPath)
Gets a UTC timezoned date from a ISO 8601
date string element using the
specified JsonPath
.
Date
getDate(String jsonPath,
Date defaultElement)
Gets a UTC timezoned date from a ISO 8601
date string element using the
specified JsonPath
.
Double
getDouble(String jsonPath)
Gets an element as Double
using the
specified JsonPath
.
Double
getDouble(String jsonPath,
Double defaultElement)
Gets an element as Double
using the
specified JsonPath
.
Float
getFloat(String jsonPath)
Gets an element as Float
using the
specified JsonPath
.
Float
getFloat(String jsonPath,
Float defaultElement)
Gets an element as Float
using the
specified JsonPath
.
Instant
getInstant(String jsonPath)
Gets an Instant from a ISO 8601
date string element using the
specified JsonPath
.
Instant
getInstant(String jsonPath,
Instant defaultElement)
Gets an Instant from a ISO 8601
date string element using the
specified JsonPath
.
Integer
getInteger(String jsonPath)
Gets an element as Integer
using the
specified JsonPath
.
Integer
getInteger(String jsonPath,
Integer defaultElement)
Gets an element as Integer
using the
specified JsonPath
.
JsonArray
getJsonArray(String jsonPath)
Gets an element as JsonArray
using the
specified JsonPath
.
JsonArray
getJsonArray(String jsonPath,
JsonArray defaultElement)
Gets an element as JsonArray
using the
specified JsonPath
.
JsonArray
getJsonArrayOrEmpty(String jsonPath)
Gets an element as JsonArray
using the
specified JsonPath
.
JsonArray
getJsonArrayOrEmpty(String jsonPath,
boolean addIfDoesntExist)
Gets an element as JsonArray
using the
specified JsonPath
.
JsonObject
getJsonObject(String jsonPath)
Gets an element as JsonObject
using the
specified JsonPath
.
JsonObject
getJsonObject(String jsonPath,
JsonObject defaultElement)
Gets an element as JsonObject
using the
specified JsonPath
.
JsonObject
getJsonObjectOrEmpty(String jsonPath)
Gets an element as JsonObject
using the
specified JsonPath
.
JsonObject
getJsonObjectOrEmpty(String jsonPath,
boolean addIfDoesntExist)
Gets an element as JsonObject
using the
specified JsonPath
.
Long
getLong(String jsonPath)
Gets an element as Long
using the
specified JsonPath
.
Long
getLong(String jsonPath,
Long defaultElement)
Gets an element as Long
using the
specified JsonPath
.
Object
getObject(String jsonPath)
Gets an untyped Object using the
specified JsonPath
.
Object
getObject(String jsonPath,
Object defaultElement)
Gets an untyped Object using the
specified JsonPath
.
String
getString(String jsonPath)
Gets an element as String
using the
specified JsonPath
.
String
getString(String jsonPath,
String defaultElement)
Gets an element as String
using the
specified JsonPath
.
boolean
isCanBeConvertedToBigDecimal(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type BigDecimal
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToBoolean(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Boolean
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToByteArray(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type base 64 String
representing
a byte array, or can be converted and retrieved as one.
boolean
isCanBeConvertedToDate(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Date
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToDouble(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Double
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToFloat(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Float
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToInteger(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Integer
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToJsonArray(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type JsonArray
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToJsonObject(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type JsonObject
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToLong(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Long
, or can be
converted and retrieved as one.
boolean
isCanBeConvertedToString(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type String
, or can be
converted and retrieved as one.
boolean
isMutable()
Is this object/array mutable?
boolean
isNull(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is null
.
boolean
isOfTypeBigDecimal(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type BigDecimal
, without requiring
any conversion.
boolean
isOfTypeBoolean(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Boolean
, without requiring
any conversion.
boolean
isOfTypeByteArray(String jsonPath,
boolean acceptBase64StringToo)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type byte[]
, without requiring
any conversion.
boolean
isOfTypeDate(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Date
, without requiring
any conversion.
boolean
isOfTypeDouble(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Double
, without requiring
any conversion.
boolean
isOfTypeFloat(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Float
, without requiring
any conversion.
boolean
isOfTypeInteger(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Integer
, without requiring
any conversion.
boolean
isOfTypeJsonArray(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type JsonArray
, without requiring
any conversion.
boolean
isOfTypeJsonObject(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type JsonObject
, without requiring
any conversion.
boolean
isOfTypeLong(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Long
, without requiring
any conversion.
boolean
isOfTypeString(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type String
, without requiring
any conversion.
JsonObjectOrArray
remove(String jsonPath)
Removes an element at JsonPath
.
JsonObjectOrArray
set(String jsonPath,
Object element)
Sets an element at the specified JsonPath
.
JsonObjectOrArray
set(String jsonPath,
Object element,
boolean clone)
Sets an element at the specified JsonPath
.
int
size()
The size of the object.
String
toJsonString()
The Json
string representation
of the object.
String
toJsonString(boolean pretty)
The Json
string representation
of the object.
void
transform(String jsonPath,
ElementTransformer transformer)
Transforms the element at the specified JsonPath
using
the transformer.
void
transformAll(ElementTransformer transformer)
Transforms all the elements of the object, using the specified
transformer.
void
transformAll(ElementTransformer transformer,
boolean recursive)
Transforms all the elements of the object, using the specified
transformer.
void
trim(String jsonPath)
Trims the element at the specified JsonPath
if
it's of type String
.
void
trimAll()
Trims all the elements of the object that are of type
String
.
void
trimAll(boolean recursive)
Trims all the elements of the object that are of type
String.
-
-
Method Detail
-
transform
void transform(String jsonPath,
ElementTransformer transformer)
Transforms the element at the specified JsonPath
using
the transformer.
-
isMutable
boolean isMutable()
Is this object/array mutable?
-
clear
JsonObjectOrArray clear()
Clears all elements.
-
size
int size()
The size of the object.
-
toJsonString
String toJsonString()
The Json
string representation
of the object.
-
toJsonString
String toJsonString(boolean pretty)
The Json
string representation
of the object.
- Parameters:
pretty
- if true
, the generated String will
be formatted.
-
clone
JsonObjectOrArray clone(boolean mutable)
Clone the object.
- Parameters:
mutable
- if false
, the resulting
object will be immutable.
-
transformAll
void transformAll(ElementTransformer transformer)
Transforms all the elements of the object, using the specified
transformer. This transformation is not recursive.
-
transformAll
void transformAll(ElementTransformer transformer,
boolean recursive)
Transforms all the elements of the object, using the specified
transformer.
- Parameters:
recursive
- if true
,
then all children elements will also be transformed,
recursively.
-
trim
void trim(String jsonPath)
Trims the element at the specified JsonPath
if
it's of type String
.
-
trimAll
void trimAll()
Trims all the elements of the object that are of type
String
. This transformation is not recursive.
-
trimAll
void trimAll(boolean recursive)
Trims all the elements of the object that are of type
String.
- Parameters:
recursive
- if true
,
then all children elements will also be trimmed,
recursively.
-
contains
boolean contains(String jsonPath)
Does the object contain an element at
the JsonPath
position (even if
null
)?
-
remove
JsonObjectOrArray remove(String jsonPath)
Removes an element at JsonPath
.
- Returns:
- the current object (fluent style).
-
set
JsonObjectOrArray set(String jsonPath,
Object element)
Sets an element at the specified JsonPath
.
Overwrites any existing element at that JsonPath
.
The required hierarchy will be created, if required, to
support the JsonPath
.
If the object to add is not of a JsonObject's native type,
the object is converted to a JsonObject or a
JsonArray before being added. Once the object is converted
and added, a modification to the original object won't
affect the added element, and vice-versa.
If the element to add is a JsonObject
or
a JsonArray
and is immutable then
it will be cloned.
Doing so, we can make sure that the current object 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 a JsonArray
using the associated
conversion method.
Those are the types of object that will be converted to a
JsonArray instead of a JsonObject, if no conversion interface
is implemented :
-
A Collection
-
An array
-
set
JsonObjectOrArray set(String jsonPath,
Object element,
boolean clone)
Sets an element at the specified JsonPath
.
Overwrites any existing element at that JsonPath
.
The required hierarchy will be created, if required, to
support the JsonPath
.
If the object to add is not of a JsonObject's native type,
the object is converted to a JsonObject or a
JsonArray before being added. Once the object is converted
and added, a modification to the original object won't
affect the added element, and vice-versa.
If the element to add is a JsonObject
or
a JsonArray
and is immutable then
it will be cloned.
Doing so, we can make sure that the current object 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 a JsonArray
using the associated
conversion method.
Those are the types of object 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 the current object is always
fully mutable or fully immutable.
-
getJsonObject
JsonObject getJsonObject(String jsonPath)
throws CantConvertException
Gets an element as JsonObject
using the
specified JsonPath
.
- Returns:
- the object or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getJsonObject
JsonObject getJsonObject(String jsonPath,
JsonObject defaultElement)
throws CantConvertException
Gets an element as JsonObject
using the
specified JsonPath
.
- Returns:
- the object or the specified
defaultElement
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getJsonObjectOrEmpty
JsonObject getJsonObjectOrEmpty(String jsonPath)
throws CantConvertException
Gets an element as JsonObject
using the
specified JsonPath
.
- Returns:
- the element or an empty
JsonObject
if not found or if null
. The empty
JsonObject
will not be added to the specified
path.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getJsonObjectOrEmpty
JsonObject getJsonObjectOrEmpty(String jsonPath,
boolean addIfDoesntExist)
throws CantConvertException
Gets an element as JsonObject
using the
specified JsonPath
.
- Parameters:
addIfDoesntExist
- if true
and the element doesn't exist,
the created empty JsonObject
will be added to the specified
JsonPath
.
- 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.
-
getJsonArray
JsonArray getJsonArray(String jsonPath)
throws CantConvertException
Gets an element as JsonArray
using the
specified JsonPath
.
- Returns:
- the object or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getJsonArray
JsonArray getJsonArray(String jsonPath,
JsonArray defaultElement)
throws CantConvertException
Gets an element as JsonArray
using the
specified JsonPath
.
- Returns:
- the object or the specified
defaultElement
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getJsonArrayOrEmpty
JsonArray getJsonArrayOrEmpty(String jsonPath)
throws CantConvertException
Gets an element as JsonArray
using the
specified JsonPath
.
- Returns:
- the element or an empty
JsonArray
if not found or if null
. The empty
JsonArray
will not be added to the specified
path.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getJsonArrayOrEmpty
JsonArray getJsonArrayOrEmpty(String jsonPath,
boolean addIfDoesntExist)
throws CantConvertException
Gets an element as JsonArray
using the
specified JsonPath
.
- Parameters:
addIfDoesntExist
- if true
and the element doesn't exist,
the created empty JsonArray
will be added to the specified
JsonPath
.
- 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.
-
getString
String getString(String jsonPath)
Gets an element as String
using the
specified JsonPath
.
- Returns:
- the element or
null
if not found.
-
getString
String getString(String jsonPath,
String defaultElement)
Gets an element as String
using the
specified JsonPath
.
- Returns:
- the element or the specified
defaultElement
if not found.
-
getInteger
Integer getInteger(String jsonPath)
throws CantConvertException
Gets an element as Integer
using the
specified JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getInteger
Integer getInteger(String jsonPath,
Integer defaultElement)
throws CantConvertException
Gets an element as Integer
using the
specified 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.
-
getLong
Long getLong(String jsonPath)
throws CantConvertException
Gets an element as Long
using the
specified JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getLong
Long getLong(String jsonPath,
Long defaultElement)
throws CantConvertException
Gets an element as Long
using the
specified 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.
-
getFloat
Float getFloat(String jsonPath)
throws CantConvertException
Gets an element as Float
using the
specified JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getFloat
Float getFloat(String jsonPath,
Float defaultElement)
throws CantConvertException
Gets an element as Float
using the
specified 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.
-
getDouble
Double getDouble(String jsonPath)
throws CantConvertException
Gets an element as Double
using the
specified JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getDouble
Double getDouble(String jsonPath,
Double defaultElement)
throws CantConvertException
Gets an element as Double
using the
specified 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.
-
getBoolean
Boolean getBoolean(String jsonPath)
throws CantConvertException
Gets an element as Boolean
using the
specified JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getBoolean
Boolean getBoolean(String jsonPath,
Boolean defaultElement)
throws CantConvertException
Gets an element as Boolean
using the
specified 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.
-
getBigDecimal
BigDecimal getBigDecimal(String jsonPath)
throws CantConvertException
Gets an element as BigDecimal
using the
specified JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getBigDecimal
BigDecimal getBigDecimal(String jsonPath,
BigDecimal defaultElement)
throws CantConvertException
Gets an element as BigDecimal
using the
specified 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.
-
getBytesFromBase64String
byte[] getBytesFromBase64String(String jsonPath)
throws CantConvertException
Gets a byte array, from a base 64 encoded element using the
specified JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getBytesFromBase64String
byte[] getBytesFromBase64String(String jsonPath,
byte[] defaultElement)
throws CantConvertException
Gets a byte array, from a base 64 encoded element using the
specified 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.
-
getDate
Date getDate(String jsonPath)
throws CantConvertException
Gets a UTC timezoned date from a ISO 8601
date string element using the
specified JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getDate
Date getDate(String jsonPath,
Date defaultElement)
throws CantConvertException
Gets a UTC timezoned date from a ISO 8601
date string element using the
specified 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.
-
getInstant
Instant getInstant(String jsonPath)
throws CantConvertException
Gets an Instant from a ISO 8601
date string element using the
specified JsonPath
.
- Returns:
- the element or
null
if not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getInstant
Instant getInstant(String jsonPath,
Instant defaultElement)
throws CantConvertException
Gets an Instant from a ISO 8601
date string element using the
specified 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.
-
getObject
Object getObject(String jsonPath)
Gets an untyped Object using the
specified JsonPath
.
- Returns:
- the object or
null
if not found. This object
will necessarily be of a type managed by JsonObjectOrArray
, since
an object of any other type is automatically converted when added.
-
getObject
Object getObject(String jsonPath,
Object defaultElement)
Gets an untyped Object using the
specified JsonPath
.
- Returns:
- the object or the specified
defaultElement
if not found. This object
will necessarily be of a type managed by JsonObjectOrArray
, since
an object of any other type is automatically converted when added.
-
getArrayFirstJsonObject
JsonObject getArrayFirstJsonObject(String jsonPath)
throws CantConvertException
Gets the first value (as JsonObject) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstJsonObject
JsonObject getArrayFirstJsonObject(String jsonPath,
JsonObject defaultElement)
throws CantConvertException
Gets the first value (as JsonObject) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
getArrayFirstJsonArray
JsonArray getArrayFirstJsonArray(String jsonPath)
throws CantConvertException
Gets the first value (as JsonArray) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstJsonArray
JsonArray getArrayFirstJsonArray(String jsonPath,
JsonArray defaultElement)
throws CantConvertException
Gets the first value (as JsonArray) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
getArrayFirstString
String getArrayFirstString(String jsonPath)
Gets the first value (as String) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
-
getArrayFirstString
String getArrayFirstString(String jsonPath,
String defaultElement)
Gets the first value (as String) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or the specified
defaultElement
if the array or
the first element are not found.
-
getArrayFirstInteger
Integer getArrayFirstInteger(String jsonPath)
throws CantConvertException
Gets the first value (as Integer) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstInteger
Integer getArrayFirstInteger(String jsonPath,
Integer defaultElement)
throws CantConvertException
Gets the first value (as Integer) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
getArrayFirstLong
Long getArrayFirstLong(String jsonPath)
throws CantConvertException
Gets the first value (as Long) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstLong
Long getArrayFirstLong(String jsonPath,
Long defaultElement)
throws CantConvertException
Gets the first value (as Long) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
getArrayFirstDouble
Double getArrayFirstDouble(String jsonPath)
throws CantConvertException
Gets the first value (as Double) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstDouble
Double getArrayFirstDouble(String jsonPath,
Double defaultElement)
throws CantConvertException
Gets the first value (as Double) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
getArrayFirstFloat
Float getArrayFirstFloat(String jsonPath)
throws CantConvertException
Gets the first value (as Float) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstFloat
Float getArrayFirstFloat(String jsonPath,
Float defaultElement)
throws CantConvertException
Gets the first value (as Float) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
getArrayFirstBoolean
Boolean getArrayFirstBoolean(String jsonPath)
throws CantConvertException
Gets the first value (as Boolean) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstBoolean
Boolean getArrayFirstBoolean(String jsonPath,
Boolean defaultElement)
throws CantConvertException
Gets the first value (as Boolean) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
getArrayFirstBigDecimal
BigDecimal getArrayFirstBigDecimal(String jsonPath)
throws CantConvertException
Gets the first value (as BigDecimal) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstBigDecimal
BigDecimal getArrayFirstBigDecimal(String jsonPath,
BigDecimal defaultElement)
throws CantConvertException
Gets the first value (as BigDecimal) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
getArrayFirstBytesFromBase64String
byte[] getArrayFirstBytesFromBase64String(String jsonPath)
throws CantConvertException
Gets the first value (as byte[]) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstBytesFromBase64String
byte[] getArrayFirstBytesFromBase64String(String jsonPath,
byte[] defaultElement)
throws CantConvertException
Gets the first value (as byte[]) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
getArrayFirstDate
Date getArrayFirstDate(String jsonPath)
throws CantConvertException
Gets the first value (as Date) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstDate
Date getArrayFirstDate(String jsonPath,
Date defaultElement)
throws CantConvertException
Gets the first value (as Date) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
getArrayFirstInstant
Instant getArrayFirstInstant(String jsonPath)
throws CantConvertException
Gets the first value (as Instant) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property or
null
if the array or
the first element are not found.
- Throws:
CantConvertException
- if an existing element can't be converted to the
required type.
-
getArrayFirstInstant
Instant getArrayFirstInstant(String jsonPath,
Instant defaultElement)
throws CantConvertException
Gets the first value (as Instant) of a JsonArray
property
of the object, using the JsonPath
to find the array.
- Returns:
- the value of the property 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.
-
isCanBeConvertedToString
boolean isCanBeConvertedToString(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type String
, or can be
converted and retrieved as one.
-
isCanBeConvertedToInteger
boolean isCanBeConvertedToInteger(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Integer
, or can be
converted and retrieved as one.
-
isCanBeConvertedToLong
boolean isCanBeConvertedToLong(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Long
, or can be
converted and retrieved as one.
-
isCanBeConvertedToFloat
boolean isCanBeConvertedToFloat(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Float
, or can be
converted and retrieved as one.
-
isCanBeConvertedToDouble
boolean isCanBeConvertedToDouble(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Double
, or can be
converted and retrieved as one.
-
isCanBeConvertedToBoolean
boolean isCanBeConvertedToBoolean(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Boolean
, or can be
converted and retrieved as one.
-
isCanBeConvertedToBigDecimal
boolean isCanBeConvertedToBigDecimal(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type BigDecimal
, or can be
converted and retrieved as one.
-
isCanBeConvertedToByteArray
boolean isCanBeConvertedToByteArray(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type base 64 String
representing
a byte array, or can be converted and retrieved as one.
-
isCanBeConvertedToDate
boolean isCanBeConvertedToDate(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type Date
, or can be
converted and retrieved as one.
-
isCanBeConvertedToJsonObject
boolean isCanBeConvertedToJsonObject(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type JsonObject
, or can be
converted and retrieved as one.
-
isCanBeConvertedToJsonArray
boolean isCanBeConvertedToJsonArray(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
, of type JsonArray
, or can be
converted and retrieved as one.
-
isOfTypeString
boolean isOfTypeString(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type String
, without requiring
any conversion.
-
isOfTypeInteger
boolean isOfTypeInteger(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Integer
, without requiring
any conversion.
-
isOfTypeLong
boolean isOfTypeLong(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Long
, without requiring
any conversion.
-
isOfTypeFloat
boolean isOfTypeFloat(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Float
, without requiring
any conversion.
-
isOfTypeDouble
boolean isOfTypeDouble(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Double
, without requiring
any conversion.
-
isOfTypeBoolean
boolean isOfTypeBoolean(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Boolean
, without requiring
any conversion.
-
isOfTypeBigDecimal
boolean isOfTypeBigDecimal(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type BigDecimal
, without requiring
any conversion.
-
isOfTypeByteArray
boolean isOfTypeByteArray(String jsonPath,
boolean acceptBase64StringToo)
Validates that the value at the specified 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.
-
isOfTypeDate
boolean isOfTypeDate(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type Date
, without requiring
any conversion.
-
isOfTypeJsonObject
boolean isOfTypeJsonObject(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type JsonObject
, without requiring
any conversion.
-
isOfTypeJsonArray
boolean isOfTypeJsonArray(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is currently null
or of type JsonArray
, without requiring
any conversion.
-
isNull
boolean isNull(String jsonPath)
Validates that the value at the specified JsonPath
exists and
is null
.
Copyright © 2019. All rights reserved.