com.github.fge.jsonpatch
Class MoveOperation

java.lang.Object
  extended by com.github.fge.jsonpatch.JsonPatchOperation
      extended by com.github.fge.jsonpatch.DualPathOperation
          extended by com.github.fge.jsonpatch.MoveOperation
All Implemented Interfaces:
JsonSerializable

public final class MoveOperation
extends DualPathOperation

JSON Patch 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:

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" } ]
 


Field Summary
 
Fields inherited from class com.github.fge.jsonpatch.DualPathOperation
from
 
Fields inherited from class com.github.fge.jsonpatch.JsonPatchOperation
BUNDLE, op, path
 
Constructor Summary
MoveOperation(JsonPointer from, JsonPointer path)
           
 
Method Summary
 JsonNode apply(JsonNode node)
          Apply this operation to a JSON value
 
Methods inherited from class com.github.fge.jsonpatch.DualPathOperation
serialize, serializeWithType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MoveOperation

public MoveOperation(JsonPointer from,
                     JsonPointer path)
Method Detail

apply

public JsonNode apply(JsonNode node)
               throws JsonPatchException
Description copied from class: JsonPatchOperation
Apply this operation to a JSON value

Specified by:
apply in class JsonPatchOperation
Parameters:
node - the value to patch
Returns:
the patched value
Throws:
JsonPatchException - operation failed to apply to this value