Package com.gravity9.jsonpatch
Class MoveOperation
- java.lang.Object
-
- com.gravity9.jsonpatch.JsonPatchOperation
-
- com.gravity9.jsonpatch.DualPathOperation
-
- com.gravity9.jsonpatch.MoveOperation
-
- All Implemented Interfaces:
com.fasterxml.jackson.databind.JsonSerializable
public final class MoveOperation extends DualPathOperation
JSON PatchmoveoperationFor this operation,
frompoints to the value to move, andpathpoints to the new location of the moved value.As for
add:- the value at the destination path is either created or replaced;
- it is created only if the immediate parent exists;
-appends at the end of an array.
It is an error condition if
fromdoes not point to a JSON value.The specification adds another rule that the
frompath must not be an immediate parent ofpath. Unfortunately, that doesn't really work. Consider this patch:{ "op": "move", "from": "/0", "path": "/0/x" }Even though
/0is an immediate parent of/0/x, when this patch is applied to:[ "victim", {} ]it actually succeeds and results in the patched value:
[ { "x": "victim" } ]
-
-
Field Summary
-
Fields inherited from class com.gravity9.jsonpatch.DualPathOperation
from
-
Fields inherited from class com.gravity9.jsonpatch.JsonPatchOperation
BUNDLE, op, path
-
-
Constructor Summary
Constructors Constructor Description MoveOperation(java.lang.String from, java.lang.String path)
-
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.DualPathOperation
getFrom, serialize, serializeWithType, toString
-
Methods inherited from class com.gravity9.jsonpatch.JsonPatchOperation
apply, getOp, getPath
-
-
-
-
Method Detail
-
applyInternal
public com.fasterxml.jackson.databind.JsonNode applyInternal(com.fasterxml.jackson.databind.JsonNode node) throws JsonPatchException- Specified by:
applyInternalin classJsonPatchOperation- Throws:
JsonPatchException
-
-