public interface IJsonObject extends Iterable<Map.Entry<String,Object>>
Json object "{}", and makes it easier
to get its properties in a typed way.| Modifier and Type | Method and Description |
|---|---|
IJsonObject |
clone()
Deep copy of the
IJsonObject, so any
modification to the original won't affect the
clone, and vice-versa. |
IJsonObject |
clone(boolean mutable)
Deep copy of the
IJsonObject, so any
modification to the original won't affect the
clone, and vice-versa. |
Map<String,Object> |
convertToPlainMap()
Converts the
IJsonObject to a plain Map. |
BigDecimal |
getArrayFirstBigDecimal(String key)
Gets the first value (as BigDecimal) of a
IJsonArray property
of the object. |
BigDecimal |
getArrayFirstBigDecimal(String key,
BigDecimal defaultValue)
Gets the first value (as BigDecimal) of a
IJsonArray property
of the object. |
Boolean |
getArrayFirstBoolean(String key)
Gets the first value (as Boolean) of a
IJsonArray property
of the object. |
Boolean |
getArrayFirstBoolean(String key,
Boolean defaultValue)
Gets the first value (as Boolean) of a
IJsonArray property
of the object. |
byte[] |
getArrayFirstBytesFromBase64String(String key)
Gets the first value (as byte[]) of a
IJsonArray property
of the object. |
byte[] |
getArrayFirstBytesFromBase64String(String key,
byte[] defaultValue)
Gets the first value (as byte[]) of a
IJsonArray property
of the object. |
Date |
getArrayFirstDate(String key)
Gets the first value (as Date) of a
IJsonArray property
of the object. |
Date |
getArrayFirstDate(String key,
Date defaultValue)
Gets the first value (as Date) of a
IJsonArray property
of the object. |
Double |
getArrayFirstDouble(String key)
Gets the first value (as Double) of a
IJsonArray property
of the object. |
Double |
getArrayFirstDouble(String key,
Double defaultValue)
Gets the first value (as Double) of a
IJsonArray property
of the object. |
Float |
getArrayFirstFloat(String key)
Gets the first value (as Float) of a
IJsonArray property
of the object. |
Float |
getArrayFirstFloat(String key,
Float defaultValue)
Gets the first value (as Float) of a
IJsonArray property
of the object. |
Integer |
getArrayFirstInteger(String key)
Gets the first value (as Integer) of a
IJsonArray property
of the object. |
Integer |
getArrayFirstInteger(String key,
Integer defaultValue)
Gets the first value (as Integer) of a
IJsonArray property
of the object. |
IJsonArray |
getArrayFirstJsonArray(String key)
Gets the first value (as IJsonArray) of a
IJsonArray property
of the object. |
IJsonArray |
getArrayFirstJsonArray(String key,
IJsonArray defaultValue)
Gets the first value (as IJsonArray) of a
IJsonArray property
of the object. |
IJsonObject |
getArrayFirstJsonObject(String key)
Gets the first value (as IJsonObject) of a
IJsonArray property
of the object. |
IJsonObject |
getArrayFirstJsonObject(String key,
IJsonObject defaultValue)
Gets the first value (as IJsonObject) of a
IJsonArray property
of the object. |
Long |
getArrayFirstLong(String key)
Gets the first value (as Long) of a
IJsonArray property
of the object. |
Long |
getArrayFirstLong(String key,
Long defaultValue)
Gets the first value (as Long) of a
IJsonArray property
of the object. |
String |
getArrayFirstString(String key)
Gets the first value (as String) of a
IJsonArray property
of the object. |
String |
getArrayFirstString(String key,
String defaultValue)
Gets the first value (as String) of a
IJsonArray property
of the object. |
BigDecimal |
getBigDecimal(String key)
Gets a property as
BigDecimal. |
BigDecimal |
getBigDecimal(String key,
BigDecimal defaultValue)
Gets a property as
BigDecimal. |
Boolean |
getBoolean(String key)
Gets a property as
Boolean. |
Boolean |
getBoolean(String key,
Boolean defaultValue)
Gets a property as
Boolean. |
byte[] |
getBytesFromBase64String(String key)
Gets a byte array, from a base 64 encoded property.
|
byte[] |
getBytesFromBase64String(String key,
byte[] defaultValue)
Gets a byte array, from a base 64 encoded property.
|
Date |
getDate(String key)
Gets a UTC timezoned date from a
ISO 8601 date property. |
Date |
getDate(String key,
Date defaultValue)
Gets a UTC timezoned date from a
ISO 8601 date property. |
Double |
getDouble(String key)
Gets a property as
Double. |
Double |
getDouble(String key,
Double defaultValue)
Gets a property as
Double. |
Float |
getFloat(String key)
Gets a property as
Float. |
Float |
getFloat(String key,
Float defaultValue)
Gets a property as
Float. |
Integer |
getInteger(String key)
Gets a property as
Integer. |
Integer |
getInteger(String key,
Integer defaultValue)
Gets a property as
Integer. |
IJsonArray |
getJsonArray(String key)
Gets a property as
IJsonArray. |
IJsonArray |
getJsonArray(String key,
IJsonArray defaultValue)
Gets a property as
IJsonArray. |
IJsonArray |
getJsonArrayOrEmpty(String key)
Gets a property as
IJsonArray. |
IJsonObject |
getJsonObject(String key)
Gets a property as
IJsonObject. |
IJsonObject |
getJsonObject(String key,
IJsonObject defaultValue)
Gets a property as
IJsonObject. |
IJsonObject |
getJsonObjectOrEmpty(String key)
Gets a property as
IJsonObject. |
Long |
getLong(String key)
Gets a property as
Long. |
Long |
getLong(String key,
Long defaultValue)
Gets a property as
Long. |
String |
getString(String key)
Gets a property as
String. |
String |
getString(String key,
String defaultValue)
Gets a property as
String. |
boolean |
isKeyExists(String key)
Does the object contain the specified key?
|
IJsonObject |
merge(IJsonObject jsonObj)
Merges the specified
IJsonObject properties in the current
object. |
IJsonObject |
merge(IJsonObject jsonObj,
boolean clone)
Merges the specified
IJsonObject properties in the current
object. |
IJsonObject |
merge(Map<String,Object> map)
Merges all the Map's entries in the IJsonObject.
|
IJsonObject |
merge(Map<String,Object> map,
boolean clone)
Merges all the Map's entries in the IJsonObject.
|
IJsonObject |
put(String key,
BigDecimal value)
Adds a BigDecimal.
|
IJsonObject |
put(String key,
Boolean value)
Adds a Boolean.
|
IJsonObject |
put(String key,
byte[] value)
Adds a byte[].
|
IJsonObject |
put(String key,
Date value)
Adds a Date.
|
IJsonObject |
put(String key,
Double value)
Adds a Double.
|
IJsonObject |
put(String key,
Float value)
Adds a Float.
|
IJsonObject |
put(String key,
IJsonArray value)
Adds a IJsonArray.
|
IJsonObject |
put(String key,
IJsonArray value,
boolean clone)
Adds a IJsonArray.
|
IJsonObject |
put(String key,
IJsonObject value)
Adds a IJsonObject.
|
IJsonObject |
put(String key,
IJsonObject value,
boolean clone)
Adds a IJsonObject.
|
IJsonObject |
put(String key,
Integer value)
Adds a Integer.
|
IJsonObject |
put(String key,
Long value)
Adds a Long.
|
IJsonObject |
put(String key,
String value)
Adds a String.
|
IJsonObject |
putConvert(String key,
Object value)
If the object to add is not of a IJsonObject's native type,
the object is converted to a IJsonObject or a
IJsonArray before being added.
|
IJsonObject |
putConvert(String key,
Object value,
boolean clone)
If the object to add is not of a IJsonObject's native type,
the object is converted to a IJsonObject or a
IJsonArray before being added.
|
IJsonObject |
remove(String key)
Removes a property from the object.
|
IJsonObject |
removeAll()
Removes all properties from the object.
|
String |
toJsonString()
Gets the
Json String representation of the object. |
String |
toJsonString(boolean pretty)
Gets the
Json String representation of the object. |
forEach, iterator, spliteratorIJsonObject put(String key, String value)
IJsonObject put(String key, Integer value)
IJsonObject put(String key, Long value)
IJsonObject put(String key, Float value)
IJsonObject put(String key, Double value)
IJsonObject put(String key, Boolean value)
IJsonObject put(String key, BigDecimal value)
IJsonObject put(String key, byte[] value)
IJsonObject put(String key, Date value)
IJsonObject put(String key, IJsonObject value)
IJsonObject
WILL affect the added element. There is an exception though :
if the IJsonObject to add is immutable
then it will always be cloned. Doing so, we can make sure a
IJsonObject is always
fully mutable or fully immutable.IJsonObject put(String key, IJsonObject value, boolean clone)
clone - if true, a clone of the original
IJsonObject will be made before being added.
If that case, any modification to the original IJsonObject
won't affect the added element, and vice-versa.
If the IJsonObject
to add is immutable then it will always be cloned.
Doing so, we can make sure a IJsonObject is always
fully mutable or fully immutable.IJsonObject put(String key, IJsonArray value)
IJsonArray
WILL affect the added element, and vice-versa.
There is an exception though :
if the IJsonArray to add is immutable
then it will always be cloned. Doing so, we can make sure a
IJsonObject is always
fully mutable or fully immutable.IJsonObject put(String key, IJsonArray value, boolean clone)
clone - if true, a clone of the original
IJsonArray will be made before being added.
If that case, any modification to the original IJsonArray
won't affect the added element, and vice-versa.
If the IJsonArray
to add is immutable then it will always be cloned.
Doing so, we can make sure a IJsonObject is always
fully mutable or fully immutable.IJsonObject putConvert(String key, Object value)
If the element to add is a IJsonObject or
a IJsonArray and is immutable then
it will be cloned.
Doing so, we can make sure a IJsonObject is always
fully mutable or fully immutable.
Those are the types of object that will be converted to a IJsonArray instead of a IJsonObject :
IJsonObject putConvert(String key, Object value, boolean clone)
Those are the types of object that will be converted to a IJsonArray instead of a IJsonObject :
clone - if true, and the element to add is a
IJsonObject or IJsonArray, 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
IJsonObject is always
fully mutable or fully immutable.IJsonObject merge(Map<String,Object> map)
Note that the IJsonObject and IJsonArray 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
IJsonObject is always
fully mutable or fully immutable.
Any none primitive (or BigDecimal) object will
be converted to a IJsonObject or a
IJsonArray.
Those are the types of object that will be converted to a
IJsonArray instead of a IJsonObject
IJsonObject merge(Map<String,Object> map, boolean clone)
Any none primitive (or BigDecimal) object will
be converted to a IJsonObject or a
IJsonArray.
Those are the types of object that will be converted to a
IJsonArray instead of a IJsonObject :
clone - if true, a clone of any
IJsonObject or IJsonArray 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
IJsonObject is always
fully mutable or fully immutable.IJsonObject merge(IJsonObject jsonObj)
IJsonObject properties in the current
object. Overwrites entries of the same keys.
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
IJsonObject is always
fully mutable or fully immutable.
IJsonObject merge(IJsonObject jsonObj, boolean clone)
IJsonObject properties in the current
object. Overwrites entries of the same keys.clone - if true, a clone of the original
IJsonObject 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
IJsonObject is always
fully mutable or fully immutable.IJsonObject remove(String key)
IJsonObject removeAll()
boolean isKeyExists(String key)
IJsonObject getJsonObject(String key)
IJsonObject.null if not found.
Throws an exception if an existing element can't be converted to the
required type.IJsonObject getJsonObject(String key, IJsonObject defaultValue)
IJsonObject.defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.IJsonObject getJsonObjectOrEmpty(String key)
IJsonObject.IJsonObject if not found.
Throws an exception if an existing element can't be converted to the
required type.IJsonArray getJsonArray(String key)
IJsonArray.null if not found.
Throws an exception if an existing element can't be converted to the
required type.IJsonArray getJsonArray(String key, IJsonArray defaultValue)
IJsonArray.defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.IJsonArray getJsonArrayOrEmpty(String key)
IJsonArray.IJsonArray if not found.
Throws an exception if an existing element can't be converted to the
required type.String getString(String key)
String.null if not found.
Throws an exception if an existing element can't be converted to the
required type.String getString(String key, String defaultValue)
String.defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.Integer getInteger(String key)
Integer.null if not found.
Throws an exception if an existing element can't be converted to the
required type.Integer getInteger(String key, Integer defaultValue)
Integer.defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.Long getLong(String key)
Long.null if not found.
Throws an exception if an existing element can't be converted to the
required type.Long getLong(String key, Long defaultValue)
Long.defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.Float getFloat(String key)
Float.null if not found.
Throws an exception if an existing element can't be converted to the
required type.Float getFloat(String key, Float defaultValue)
Float.defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.Double getDouble(String key)
Double.null if not found.
Throws an exception if an existing element can't be converted to the
required type.Double getDouble(String key, Double defaultValue)
Double.defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.Boolean getBoolean(String key)
Boolean.null if not found.
Throws an exception if an existing element can't be converted to the
required type.Boolean getBoolean(String key, Boolean defaultValue)
Boolean.defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.BigDecimal getBigDecimal(String key)
BigDecimal.null if not found.
Throws an exception if an existing element can't be converted to the
required type.BigDecimal getBigDecimal(String key, BigDecimal defaultValue)
BigDecimal.defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.byte[] getBytesFromBase64String(String key)
null if not found.
Throws an exception if an existing element can't be converted to the
required type.byte[] getBytesFromBase64String(String key, byte[] defaultValue)
defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.Date getDate(String key)
ISO 8601 date property.null if not found.
Throws an exception if an existing element can't be converted to the
required type.Date getDate(String key, Date defaultValue)
ISO 8601 date property.defaultValue if not found.
Throws an exception if an existing element can't be converted to the
required type.IJsonObject getArrayFirstJsonObject(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.IJsonObject getArrayFirstJsonObject(String key, IJsonObject defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.IJsonArray getArrayFirstJsonArray(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.IJsonArray getArrayFirstJsonArray(String key, IJsonArray defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.String getArrayFirstString(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.String getArrayFirstString(String key, String defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Integer getArrayFirstInteger(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Integer getArrayFirstInteger(String key, Integer defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Long getArrayFirstLong(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Long getArrayFirstLong(String key, Long defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Double getArrayFirstDouble(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Double getArrayFirstDouble(String key, Double defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Float getArrayFirstFloat(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Float getArrayFirstFloat(String key, Float defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Boolean getArrayFirstBoolean(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Boolean getArrayFirstBoolean(String key, Boolean defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.BigDecimal getArrayFirstBigDecimal(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.BigDecimal getArrayFirstBigDecimal(String key, BigDecimal defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.byte[] getArrayFirstBytesFromBase64String(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.byte[] getArrayFirstBytesFromBase64String(String key, byte[] defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Date getArrayFirstDate(String key)
IJsonArray property
of the object.null if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.Date getArrayFirstDate(String key, Date defaultValue)
IJsonArray property
of the object.defaultValue if the array or
the first element are not found.
Throws an exception if an existing element can't be converted to the
required type.String toJsonString()
Json String representation of the object.String toJsonString(boolean pretty)
Json String representation of the object.pretty - if true, the generated String will be formatted.IJsonObject clone()
IJsonObject, so any
modification to the original won't affect the
clone, and vice-versa.
The resulting IJsonObject is mutable.
IJsonObject clone(boolean mutable)
IJsonObject, so any
modification to the original won't affect the
clone, and vice-versa.mutable - if false, the resulting
IJsonObject and all its children
will be immutable.Copyright © 2016. All rights reserved.