Class AddOperation
java.lang.Object
com.linecorp.centraldogma.common.jsonpatch.JsonPatchOperation
com.linecorp.centraldogma.common.jsonpatch.AddOperation
- All Implemented Interfaces:
JsonSerializable
JSON Patch
add
operation.
For this operation, path
is the JSON Pointer where the value
should be added, and value
is the value to add.
Note that if the target value pointed to by path
already exists,
it is replaced. In this case, add
is equivalent to replace
.
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 ]
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.JsonSerializable
JsonSerializable.Base
-
Method Summary
Modifier and TypeMethodDescriptionApplies this operation to a JSON value.boolean
int
hashCode()
final void
serialize
(JsonGenerator jgen, SerializerProvider provider) final void
serializeWithType
(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) final String
toString()
value()
Returns the JSON value.Methods inherited from class com.linecorp.centraldogma.common.jsonpatch.JsonPatchOperation
add, add, asJsonArray, asJsonArray, copy, copy, move, move, op, path, remove, remove, removeIfExists, removeIfExists, replace, replace, safeReplace, safeReplace, test, test, testAbsence, testAbsence, toJsonNode
-
Method Details
-
apply
Description copied from class:JsonPatchOperation
Applies this operation to a JSON value.- Specified by:
apply
in classJsonPatchOperation
- Parameters:
node
- the value to patch- Returns:
- the patched value
-
value
Returns the JSON value. -
serialize
- Throws:
IOException
-
serializeWithType
public final void serializeWithType(JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException - Throws:
IOException
-
equals
- Overrides:
equals
in classJsonPatchOperation
-
hashCode
public int hashCode()- Overrides:
hashCode
in classJsonPatchOperation
-
toString
- Specified by:
toString
in classJsonPatchOperation
-