Package com.gravity9.jsonpatch
Class AddOperation
- java.lang.Object
-
- com.gravity9.jsonpatch.JsonPatchOperation
-
- com.gravity9.jsonpatch.PathValueOperation
-
- com.gravity9.jsonpatch.AddOperation
-
- All Implemented Interfaces:
com.fasterxml.jackson.databind.JsonSerializable
public final class AddOperation extends PathValueOperation
JSON PatchaddoperationFor this operation,
pathis the JSON Pointer where the value should be added, andvalueis the value to add.Note that if the target value pointed to by
pathalready exists, it is replaced. In this case,addis equivalent toreplace.Note also that a value will be created at the target path if and only if the immediate parent of that value exists (and is of the correct type).
Finally, if the last reference token of the JSON Pointer is
-and the immediate parent is an array, the given value is added at the end of the array. For instance, applying:{ "op": "add", "path": "/-", "value": 3 }to:
[ 1, 2 ]will give:
[ 1, 2, 3 ]
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLAST_ARRAY_ELEMENT_SYMBOL-
Fields inherited from class com.gravity9.jsonpatch.PathValueOperation
value
-
Fields inherited from class com.gravity9.jsonpatch.JsonPatchOperation
BUNDLE, op, path
-
-
Constructor Summary
Constructors Constructor Description AddOperation(java.lang.String path, com.fasterxml.jackson.databind.JsonNode value)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.JsonNodeapplyInternal(com.fasterxml.jackson.databind.JsonNode node)-
Methods inherited from class com.gravity9.jsonpatch.PathValueOperation
getValue, serialize, serializeWithType, toString
-
Methods inherited from class com.gravity9.jsonpatch.JsonPatchOperation
apply, getOp, getPath
-
-
-
-
Field Detail
-
LAST_ARRAY_ELEMENT_SYMBOL
public static final java.lang.String LAST_ARRAY_ELEMENT_SYMBOL
- See Also:
- Constant Field Values
-
-
Method Detail
-
applyInternal
public com.fasterxml.jackson.databind.JsonNode applyInternal(com.fasterxml.jackson.databind.JsonNode node) throws JsonPatchException- Specified by:
applyInternalin classJsonPatchOperation- Throws:
JsonPatchException
-
-