public final class MoveOperation extends DualPathOperation
move
operation
For this operation, from
points to the value to move, and path
points to the new location of the moved value.
As for add
:
-
appends at the end of an array.It is an error condition if from
does not point to a JSON value.
The specification adds another rule that the from
path must not be
an immediate parent of path
. Unfortunately, that doesn't really work.
Consider this patch:
{ "op": "move", "from": "/0", "path": "/0/x" }
Even though /0
is an immediate parent of /0/x
, when this
patch is applied to:
[ "victim", {} ]
it actually succeeds and results in the patched value:
[ { "x": "victim" } ]
Modifier and Type | Field and Description |
---|---|
static String |
OPERATION_NAME |
BUNDLE, from, op, path
Constructor and Description |
---|
MoveOperation(JsonPointer from,
JsonPointer path) |
Modifier and Type | Method and Description |
---|---|
JsonNode |
apply(JsonNode node)
Apply this operation to a JSON value
|
serialize, serializeWithType, toString
public static final String OPERATION_NAME
public MoveOperation(JsonPointer from, JsonPointer path)
public JsonNode apply(JsonNode node) throws JsonPatchException
JsonPatchOperation
node
- the value to patchJsonPatchException
- operation failed to apply to this value