Class JsonValue
- java.lang.Object
- 
- org.forgerock.json.JsonValue
 
- 
- 
Constructor SummaryConstructors Constructor Description JsonValue(Object object)Constructs a JSON value object with a given object.JsonValue(Object object, JsonPointer pointer)Constructs a JSON value object with a given object and pointer.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JsonValueadd(int index, Object object)Adds the specified value to the list.JsonValueadd(Object object)Adds the specified value to the end of the list.JsonValueadd(String key, Object object)Adds the specified value.JsonValueadd(JsonPointer pointer, Object object)Adds the value identified by the specified pointer, relative to this value as root.JsonValueaddIfNotNull(String key, Object object)Adds the specified object value only if it is not nullJsonValueaddPermissive(JsonPointer pointer, Object object)Adds the value identified by the specified pointer, relative to this value as root.static List<Object>array(Object... objects)Returns a mutable JSON array containing the provided objects.<V,E extends Exception>
 Vas(Function<JsonValue,V,E> transformFunction)Returns the JSON value as an object whose type (and value) is specified by a transformation function.<V,E extends Exception>
 Promise<V,E>asAsync(AsyncFunction<JsonValue,V,E> transformFunction)Returns the JSON value as a promised object whose type (and value) is specified by a transformation function.BooleanasBoolean()Returns the JSON value as aBooleanobject.Collection<Object>asCollection()Returns the JSON value as aCollectionobject.<E> Collection<E>asCollection(Class<E> type)Returns the JSON value as aCollectioncontaining objects of the specified type.DoubleasDouble()Returns the JSON value as aDoubleobject.IntegerasInteger()Returns the JSON value as anIntegerobject.List<Object>asList()Returns the JSON value as aListobject.<E> List<E>asList(Class<E> type)Returns the JSON value as aListcontaining objects of the specified type.LongasLong()Returns the JSON value as aLongobject.Map<String,Object>asMap()Returns the JSON value as aMapobject.<V> Map<String,V>asMap(Class<V> type)Returns the JSON value as aMapcontaining objects of the specified type.<E> Map<String,List<E>>asMapOfList(Class<E> elementType)Returns the JSON value as aMapcontaining a collection of objects of the specified type.NumberasNumber()Returns the JSON value as aNumberobject.StringasString()Returns the JSON value as aStringobject.voidclear()Removes all child values from this JSON value, if it has any.JsonValueclone()Returns a shallow copy of this JSON value.booleancontains(Object object)Returnstruethis JSON value contains an item with the specified value.JsonValuecopy()Returns a deep copy of this JSON value.JsonValuedefaultTo(Object object)Defaults the JSON value to the specified value if it is currentlynull.JsonValuediff(JsonValue target)Performs a deep comparison of this JSON vlaue with another JSON value, and produces a JSON Patch value, which contains the operations necessary to modify the current value to arrive at thetargetvalue.JsonValueexpect(Class<?> type)Called to enforce that the JSON value is of a particular type.static Map.Entry<String,Object>field(String key, Object value)Returns a JSON field for inclusion in a JSON object usingobject.static Map.Entry<String,Object>fieldIfNotNull(String key, Object value)Returns a JSON field for inclusion in a JSON object usingobjectonly if its value is notnull.JsonValueget(int index)Returns the specified child value.JsonValueget(String key)Returns the specified item value.JsonValueget(JsonPointer pointer)Returns the specified child value with a pointer, relative to this value as root.ObjectgetObject()Returns the raw Java object representing this JSON value.JsonPointergetPointer()Returns the pointer of the JSON value in its JSON structure.booleanisBoolean()Returnstrueif the JSON value is aBoolean.booleanisCollection()Returnstrueif the JSON value is aCollection.booleanisDefined(String key)Returnstrueif this JSON value contains the specified item.booleanisEqualTo(JsonValue other)Performs a deep comparison of this JSON value with another JSON value, and returns whether the two objects are identical.booleanisList()Returnstrueif the JSON value is aList.booleanisMap()Returnstrueif the JSON value is aMap.booleanisNotNull()Returnstrueif the value is notnull.booleanisNull()Returnstrueif the value isnull.booleanisNumber()Returnstrueif the JSON value is aNumber.booleanisString()Returnstrueif the JSON value is aString.Iterator<JsonValue>iterator()Returns an iterator over the child values that this JSON value contains.static JsonValuejson(Object object)Returns a JSON value whose content is the provided object.Set<String>keys()Returns the set of keys for this JSON value's child values.JsonValuemerge(JsonValue other)Creates a new JSON value which combines the contents this JSON value with another.static Map<String,Object>object(int size)Produces an empty JSON object pre-allocated forsizefields.static Map<String,Object>object(Map.Entry<String,Object>... fields)Returns a JSON object comprised of the provided JSONfields.voidpatch(JsonValue patch)Applies a set of modifications in a JSON patch value to the current object, resulting in the intended target value.JsonValueput(int index, Object object)Sets the value of the specified child list element.JsonValueput(String key, Object object)Sets the value of the specified member.JsonValueput(JsonPointer pointer, Object object)Sets the value identified by the specified pointer, relative to this value as root.JsonValueputIfNotNull(String key, Object object)Sets the value of the specified member, only if it is not null.JsonValueputPermissive(JsonPointer pointer, Object object)Sets the value identified by the specified pointer, relative to this value as root.voidremove(int index)Removes the specified child value, shifting any subsequent elements to the left.voidremove(String key)Removes the specified child value.voidremove(JsonPointer pointer)Removes the specified child value with a pointer, relative to this value as root.JsonValuerequired()Throws aJsonValueExceptionif the JSON value isnull.voidsetObject(Object object)Sets the Java object representing this JSON value.intsize()Returns the number of values that this JSON value contains.Stream<JsonValue>stream()Construct a Stream from this JsonValue object.static inttoIndex(String key)Returns the key as an list index value.StringtoString()Returns a string representation of the JSON value.- 
Methods inherited from class java.lang.Objectequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.lang.IterableforEach, spliterator
 
- 
 
- 
- 
- 
Constructor Detail- 
JsonValuepublic JsonValue(Object object) Constructs a JSON value object with a given object. This constructor will automatically unwrapJsonValueobjects.- Parameters:
- object- the Java object representing the JSON value.
 
 - 
JsonValuepublic JsonValue(Object object, JsonPointer pointer) Constructs a JSON value object with a given object and pointer. This constructor will automatically unwrapJsonValueobjects.- Parameters:
- object- the Java object representing the JSON value.
- pointer- the pointer to the value in a JSON structure.
 
 
- 
 - 
Method Detail- 
arraypublic static List<Object> array(Object... objects) Returns a mutable JSON array containing the provided objects. This method is provided as a convenience method for constructing JSON arrays. Example usage:JsonValue value = json(array(1, 2, 3)); - Parameters:
- objects- The array elements.
- Returns:
- A JSON array.
 
 - 
fieldIfNotNullpublic static Map.Entry<String,Object> fieldIfNotNull(String key, Object value) Returns a JSON field for inclusion in a JSON object usingobjectonly if its value is notnull. Example usage:JsonValue value = json(object(fieldIfNotNull("uid", getUid()));Note: This feature depends on the object(java.util.Map.Entry...)method that checks if the entry is notnullbefore including it into the map.- Parameters:
- key- The JSON field name.
- value- The JSON field value (may be- null).
- Returns:
- The JSON field for inclusion in a JSON object or null.
- See Also:
- object(java.util.Map.Entry...)
 
 - 
fieldpublic static Map.Entry<String,Object> field(String key, Object value) Returns a JSON field for inclusion in a JSON object usingobject. This method is provided as a convenience method for constructing JSON objects. Example usage:JsonValue value = json(object(field("uid", "bjensen"), field("age", 30)));- Parameters:
- key- The JSON field name.
- value- The JSON field value.
- Returns:
- The JSON field for inclusion in a JSON object.
 
 - 
jsonpublic static JsonValue json(Object object) Returns a JSON value whose content is the provided object. This method is provided as a convenience method for constructing JSON objects, instead of usingJsonValue(Object). Example usage:JsonValue value = json(object(field("uid", "bjensen"), field("roles", array("sales", "marketing"))));- Parameters:
- object- the Java object representing the JSON value.
- Returns:
- The JSON value.
 
 - 
object@SafeVarargs public static Map<String,Object> object(Map.Entry<String,Object>... fields) Returns a JSON object comprised of the provided JSONfields. This method is provided as a convenience method for constructing JSON objects. Example usage:JsonValue value = json(object(field("uid", "bjensen"), field("age", 30)));- Parameters:
- fields- The list of- fieldsto include in the JSON object.- nullelements are allowed, but are not included in the returned map (this makes it easier to include optional elements).
- Returns:
- The JSON object.
 
 - 
objectpublic static Map<String,Object> object(int size) Produces an empty JSON object pre-allocated forsizefields. This method is provided as a convenience method for constructing JSON objects. Example usage:JsonValue value = json(object(20)); for (Map.Entry<String, Object> entry : someMap.entrySet()) { value.put(entry.getKey(), entry.getValue()); }- Parameters:
- size- The size of the JSON object to allocate.
- Returns:
- The [empty] JSON object.
 
 - 
toIndexpublic static int toIndex(String key) Returns the key as an list index value. If the string does not represent a valid list index value, then-1is returned.- Parameters:
- key- the key to be converted into an list index value.
- Returns:
- the converted index value, or -1if invalid.
 
 - 
addpublic JsonValue add(int index, Object object) Adds the specified value to the list. Adding a value to a list shifts any existing elements at or above the specified index to the right by one.- Parameters:
- index- the- Listindex of the value to add.
- object- the java object to add.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if this JSON value is not a- Listor index is out of range.
 
 - 
addpublic JsonValue add(JsonPointer pointer, Object object) Adds the value identified by the specified pointer, relative to this value as root. If doing so would require the creation of a new object or list, aJsonValueExceptionwill be thrown.NOTE: values may be added to a list using the reserved JSON pointer token "-". For example, the pointer "/a/b/-" will add a new element to the list referenced by "/a/b". - Parameters:
- pointer- identifies the child value to add.
- object- the Java object value to add.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if the specified pointer is invalid.
 
 - 
addpublic JsonValue add(Object object) Adds the specified value to the end of the list. This method is equivalent to the following code:add(size(), object); - Parameters:
- object- the java object to add.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if this JSON value is not a- List.
 
 - 
addpublic JsonValue add(String key, Object object) Adds the specified value.If adding to a list value, the specified key must be parseable as an unsigned base-10 integer and be less than or equal to the list size. Adding a value to a list shifts any existing elements at or above the specified index to the right by one. - Parameters:
- key- the- Mapkey or- Listindex to add.
- object- the Java object to add.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if not a- Mapor- List, the- Mapkey already exists, or the- Listindex is out of range.
 
 - 
addIfNotNullpublic JsonValue addIfNotNull(String key, Object object) Adds the specified object value only if it is not nullFor further usage information, see documentation for add(String, Object).- Parameters:
- key- the- Mapkey or- Listindex to add.
- object- the Java object to add.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if not a- Mapor- List, the- Mapkey already exists, or the- Listindex is out of range.
 
 - 
addPermissivepublic JsonValue addPermissive(JsonPointer pointer, Object object) Adds the value identified by the specified pointer, relative to this value as root. Missing parent objects or lists will be created on demand.NOTE: values may be added to a list using the reserved JSON pointer token "-". For example, the pointer "/a/b/-" will add a new element to the list referenced by "/a/b". - Parameters:
- pointer- identifies the child value to add.
- object- the Java object value to add.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if the specified pointer is invalid.
 
 - 
asBooleanpublic Boolean asBoolean() - Returns:
- the boolean value.
- Throws:
- JsonValueException- if the JSON value is not a boolean type.
 
 - 
asDoublepublic Double asDouble() Returns the JSON value as aDoubleobject. This may involve rounding. If the JSON value isnull, this method returnsnull.- Returns:
- the double-precision floating point value.
- Throws:
- JsonValueException- if the JSON value is not a number.
 
 - 
asIntegerpublic Integer asInteger() Returns the JSON value as anIntegerobject. This may involve rounding or truncation. If the JSON value isnull, this method returnsnull.- Returns:
- the integer value.
- Throws:
- JsonValueException- if the JSON value is not a number.
 
 - 
asCollectionpublic Collection<Object> asCollection() - Returns:
- the collection value, or nullif no value.
- Throws:
- JsonValueException- if the JSON value is not a- Collection.
 
 - 
asListpublic List<Object> asList() Returns the JSON value as aListobject. If the JSON value isnull, this method returnsnull. The returnedListis not a copy : any interaction with it will affect theJsonValue.- Returns:
- the list value, or nullif no value.
- Throws:
- JsonValueException- if the JSON value is not a- List.
 
 - 
asCollectionpublic <E> Collection<E> asCollection(Class<E> type) Returns the JSON value as aCollectioncontaining objects of the specified type. If the value isnull, this method returnsnull. If any of the elements of the collection are notnulland not of the specified type,JsonValueExceptionis thrown. The returnedCollectionis not a copy : any interaction with it will affect theJsonValue.- Type Parameters:
- E- the type of elements in this collection
- Parameters:
- type- the type of object that all elements are expected to be.
- Returns:
- the collection value, or nullif no value.
- Throws:
- JsonValueException- if the JSON value is not a- Collectionor contains an unexpected type.
- NullPointerException- if- typeis- null.
 
 - 
asListpublic <E> List<E> asList(Class<E> type) Returns the JSON value as aListcontaining objects of the specified type. If the value isnull, this method returnsnull. If any of the elements of the list are notnulland not of the specified type,JsonValueExceptionis thrown. The returnedListis not a copy : any interaction with it will affect theJsonValue.- Type Parameters:
- E- the type of elements in this list
- Parameters:
- type- the type of object that all elements are expected to be.
- Returns:
- the list value, or nullif no value.
- Throws:
- JsonValueException- if the JSON value is not a- Listor contains an unexpected type.
- NullPointerException- if- typeis- null.
 
 - 
aspublic <V,E extends Exception> V as(Function<JsonValue,V,E> transformFunction) throws E extends Exception Returns the JSON value as an object whose type (and value) is specified by a transformation function. It is up to the transformation function to transform/enforce source types of the elements in the Json source element and to decide what to do depending on the kind ofJsonValue: if it is null, aString, aList, orMap. If the type-transformation cannot occur, the exception specified by the transformation function is thrown.- Type Parameters:
- V- the type of element
- E- the type of exception thrown by the transformation function
- Parameters:
- transformFunction- a- Functionto transform the JsonValue element to the desired type
- Returns:
- the value, or nullif no value.
- Throws:
- E- if the JsonValue element cannot be transformed
- NullPointerException- if- transformFunctionis- null.
- E extends Exception
 
 - 
asAsyncpublic <V,E extends Exception> Promise<V,E> asAsync(AsyncFunction<JsonValue,V,E> transformFunction) Returns the JSON value as a promised object whose type (and value) is specified by a transformation function. It is up to the transformation function to transform/enforce source types of the elements in the Json source element and to decide what to do depending on the kind ofJsonValue: if it is null, aString, aList, orMap. If the type-transformation cannot occur, the exception specified by the transformation function is thrown.- Type Parameters:
- V- the type of element
- E- the type of exception thrown by the transformation function
- Parameters:
- transformFunction- a- Functionto transform the JsonValue element to the desired type
- Returns:
- the promise of the value, the final value may be null, but the promise itself can't. In case of exception the result promise is failed and contains the exception.
 
 - 
asLongpublic Long asLong() Returns the JSON value as aLongobject. This may involve rounding or truncation. If the JSON value isnull, this method returnsnull.- Returns:
- the long integer value.
- Throws:
- JsonValueException- if the JSON value is not a number.
 
 - 
asMappublic Map<String,Object> asMap() Returns the JSON value as aMapobject. If the JSON value isnull, this method returnsnull.- Returns:
- the map value, or nullif no value.
- Throws:
- JsonValueException- if the JSON value is not a- Map.
 
 - 
asMappublic <V> Map<String,V> asMap(Class<V> type) Returns the JSON value as aMapcontaining objects of the specified type. If the value isnull, this method returnsnull. If any of the values of the map are notnulland not of the specified type,JsonValueExceptionis thrown.- Type Parameters:
- V- the type of values in this map
- Parameters:
- type- the type of object that all values are expected to be.
- Returns:
- the map value, or nullif no value.
- Throws:
- JsonValueException- if the JSON value is not a- Mapor contains an unexpected type.
- NullPointerException- if- typeis- null.
 
 - 
asMapOfListpublic <E> Map<String,List<E>> asMapOfList(Class<E> elementType) Returns the JSON value as aMapcontaining a collection of objects of the specified type. If the value isnull, this method returnsnull. If any of the values of the map are notnulland not of the specified type,JsonValueExceptionis thrown.- Type Parameters:
- E- the type of elements in the collection
- Parameters:
- elementType- the type of object that all collection elements are expected to be.
- Returns:
- the map value, or nullif no value.
- Throws:
- JsonValueException- if the JSON value is not a- Mapor contains an unexpected type.
- NullPointerException- if- typeis- null.
 
 - 
asNumberpublic Number asNumber() Returns the JSON value as aNumberobject. If the JSON value isnull, this method returnsnull.- Returns:
- the numeric value.
- Throws:
- JsonValueException- if the JSON value is not a number.
 
 - 
asStringpublic String asString() Returns the JSON value as aStringobject. If the JSON value isnull, this method returnsnull.- Returns:
- the string value.
- Throws:
- JsonValueException- if the JSON value is not a string.
 
 - 
clearpublic void clear() Removes all child values from this JSON value, if it has any.
 - 
clonepublic JsonValue clone() Returns a shallow copy of this JSON value. If this JSON value contains aMapor aListobject, the returned JSON value will contain a shallow copy of the original contained object.The new value's members can be modified without affecting the original value. Modifying the member's members will almost certainly affect the original value. To avoid this, use the copy()method to return a deep copy of the JSON value.This method does not traverse the value's members, nor will it apply any transformations. 
 - 
containspublic boolean contains(Object object) Returnstruethis JSON value contains an item with the specified value.- Parameters:
- object- the object to seek within this JSON value.
- Returns:
- trueif this value contains the specified member value.
 
 - 
copypublic JsonValue copy() Returns a deep copy of this JSON value.Note: This method is recursive, and currently has no ability to detect or correct for structures containing cyclic references. Processing such a structure will result in a StackOverflowErrorbeing thrown.- Returns:
- a deep copy of this JSON value.
 
 - 
defaultTopublic JsonValue defaultTo(Object object) Defaults the JSON value to the specified value if it is currentlynull.- Parameters:
- object- the object to default to.
- Returns:
- this JSON value or a new JSON value containing the default value.
 
 - 
expectpublic JsonValue expect(Class<?> type) Called to enforce that the JSON value is of a particular type. A value ofnullis allowed.- Parameters:
- type- the class that the underlying value must have.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if the value is not the specified type.
 
 - 
getpublic JsonValue get(int index) Returns the specified child value. If this JSON value is not aListor if no such child exists, then a JSON value containing anullis returned.- Parameters:
- index- index of child element value to return.
- Returns:
- the child value, or a JSON value containing null.
- Throws:
- JsonValueException- if index is negative.
 
 - 
getpublic JsonValue get(JsonPointer pointer) Returns the specified child value with a pointer, relative to this value as root. If the specified child value does not exist, thennullis returned.- Parameters:
- pointer- the JSON pointer identifying the child value to return.
- Returns:
- the child value, or nullif no such value exists.
 
 - 
getpublic JsonValue get(String key) Returns the specified item value. If no such member value exists, then a JSON value containingnullis returned.- Parameters:
- key- the- Mapkey or- Listindex identifying the item to return.
- Returns:
- a JSON value containing the value or null.
 
 - 
getObjectpublic Object getObject() Returns the raw Java object representing this JSON value.- Returns:
- the raw Java object representing this JSON value.
 
 - 
getPointerpublic JsonPointer getPointer() Returns the pointer of the JSON value in its JSON structure.- Returns:
- the pointer of the JSON value in its JSON structure.
 
 - 
isBooleanpublic boolean isBoolean() Returnstrueif the JSON value is aBoolean.- Returns:
- trueif the JSON value is a- Boolean.
 
 - 
isDefinedpublic boolean isDefined(String key) Returnstrueif this JSON value contains the specified item.- Parameters:
- key- the- Mapkey or- Listindex of the item to seek.
- Returns:
- trueif this JSON value contains the specified member.
- Throws:
- NullPointerException- if- keyis- null.
 
 - 
isCollectionpublic boolean isCollection() Returnstrueif the JSON value is aCollection.- Returns:
- trueif the JSON value is a- Collection.
 
 - 
isListpublic boolean isList() Returnstrueif the JSON value is aList.- Returns:
- trueif the JSON value is a- List.
 
 - 
isMappublic boolean isMap() Returnstrueif the JSON value is aMap.- Returns:
- trueif the JSON value is a- Map.
 
 - 
isNullpublic boolean isNull() Returnstrueif the value isnull.- Returns:
- trueif the value is- null.
 
 - 
isNotNullpublic boolean isNotNull() Returnstrueif the value is notnull.- Returns:
- trueif the value is not- null.
 
 - 
isNumberpublic boolean isNumber() Returnstrueif the JSON value is aNumber.- Returns:
- trueif the JSON value is a- Number.
 
 - 
isStringpublic boolean isString() Returnstrueif the JSON value is aString.- Returns:
- trueif the JSON value is a- String.
 
 - 
iteratorpublic Iterator<JsonValue> iterator() Returns an iterator over the child values that this JSON value contains. If this value is aMap, then the order of the resulting child values is undefined. Calling theIterator.remove()method of the returned iterator will throw aUnsupportedOperationException.
 - 
keyspublic Set<String> keys() Returns the set of keys for this JSON value's child values. If this value is aMap, then the order of the resulting keys is the same as the underlying Map implementation. If there are no child values, this method returns an empty set.- Returns:
- the set of keys for this JSON value's child values.
 
 - 
putpublic JsonValue put(int index, Object object) Sets the value of the specified child list element.- Parameters:
- index- the- Listindex identifying the child value to set.
- object- the Java value to assign to the list element.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if this JSON value is not a- Listor index is out of range.
 
 - 
putIfNotNullpublic JsonValue putIfNotNull(String key, Object object) Sets the value of the specified member, only if it is not null.For further usage information, see documentation for put(String, Object).- Parameters:
- key- the- Mapkey or- Listindex identifying the child value to set.
- object- the object value to assign to the member.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if this JSON value is not a- Mapor- List.
- NullPointerException- if- keyis- null.
 
 - 
putpublic JsonValue put(JsonPointer pointer, Object object) Sets the value identified by the specified pointer, relative to this value as root. If doing so would require the creation of a new object or list, aJsonValueExceptionwill be thrown.NOTE: values may be added to a list using the reserved JSON pointer token "-". For example, the pointer "/a/b/-" will add a new element to the list referenced by "/a/b". - Parameters:
- pointer- identifies the child value to set.
- object- the Java object value to set.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if the specified pointer is invalid.
 
 - 
putpublic JsonValue put(String key, Object object) Sets the value of the specified member.If setting a list element, the specified key must be parseable as an unsigned base-10 integer and be less than or equal to the size of the list. - Parameters:
- key- the- Mapkey or- Listindex identifying the child value to set.
- object- the object value to assign to the member.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if this JSON value is not a- Mapor- List.
- NullPointerException- if- keyis- null.
 
 - 
putPermissivepublic JsonValue putPermissive(JsonPointer pointer, Object object) Sets the value identified by the specified pointer, relative to this value as root. Missing parent objects or lists will be created on demand.NOTE: values may be added to a list using the reserved JSON pointer token "-". For example, the pointer "/a/b/-" will add a new element to the list referenced by "/a/b". - Parameters:
- pointer- identifies the child value to set.
- object- the Java object value to set.
- Returns:
- this JSON value.
- Throws:
- JsonValueException- if the specified pointer is invalid.
 
 - 
removepublic void remove(int index) Removes the specified child value, shifting any subsequent elements to the left. If the JSON value is not aList, calling this method has no effect.- Parameters:
- index- the- Listindex identifying the child value to remove.
 
 - 
removepublic void remove(JsonPointer pointer) Removes the specified child value with a pointer, relative to this value as root. If the specified child value is not defined, calling this method has no effect.- Parameters:
- pointer- the JSON pointer identifying the child value to remove.
 
 - 
removepublic void remove(String key) Removes the specified child value. If the specified child value is not defined, calling this method has no effect.- Parameters:
- key- the- Mapkey or- Listindex identifying the child value to remove.
 
 - 
requiredpublic JsonValue required() Throws aJsonValueExceptionif the JSON value isnull.- Returns:
- this JSON value.
- Throws:
- JsonValueException- if the JSON value is- null.
 
 - 
setObjectpublic void setObject(Object object) Sets the Java object representing this JSON value.This method will automatically unwrap JsonValueobjects.- Parameters:
- object- the object to set.
 
 - 
sizepublic int size() Returns the number of values that this JSON value contains.- Returns:
- the number of values that this JSON value contains.
 
 - 
toStringpublic String toString() Returns a string representation of the JSON value. The result resembles—but is not guaranteed to conform to—JSON syntax. This method does not apply transformations to the value's children.
 - 
isEqualTopublic boolean isEqualTo(JsonValue other) Performs a deep comparison of this JSON value with another JSON value, and returns whether the two objects are identical. Fails fast in that afalseis returned as soon as a difference is detected.Note: Only values recognisable as JSON primitives ( Map,List,Number,Boolean,Stringandnull) are supported.- Parameters:
- other- another value.
- Returns:
- whether the two objects are equal.
- Throws:
- NullPointerException- if- otheris- null.
- IllegalArgumentException- if this or the- othervalue contains non-JSON primitive values.
 
 - 
diffpublic JsonValue diff(JsonValue target) Performs a deep comparison of this JSON vlaue with another JSON value, and produces a JSON Patch value, which contains the operations necessary to modify the current value to arrive at thetargetvalue.- Parameters:
- target- the intended target value.
- Returns:
- the resulting JSON Patch value.
- Throws:
- NullPointerException- if either of- originalor- targetare- null.
 
 - 
patchpublic void patch(JsonValue patch) Applies a set of modifications in a JSON patch value to the current object, resulting in the intended target value. In the event of a failure, this method does not revert any modifications applied up to the point of failure.- Parameters:
- patch- the JSON Patch value, specifying the modifications to apply to the original value.
- Throws:
- JsonValueException- if application of the patch failed.
 
 - 
mergepublic JsonValue merge(JsonValue other) Creates a new JSON value which combines the contents this JSON value with another.If there are any matching pointers in the two JSON values, then the value in otheroverrides the value inthis.- Parameters:
- other- Another JSON value which should be merged with this one.
- Returns:
- a new JSON value which combines the contents of this JSON value and other.
 
 
- 
 
-