Jsonpatch v0.6.2 Jsonpatch.Operation.Move View Source

Move operations change the position of values in map or struct.

Link to this section Summary

Functions

Move the element referenced by the JSON patch path :from to to the other given path.

Link to this section Types

Specs

t() :: %Jsonpatch.Operation.Move{from: String.t(), path: String.t()}

Link to this section Functions

Specs

apply_op(t(), map()) :: map() | :error

Move the element referenced by the JSON patch path :from to to the other given path.

Examples

iex> move = %Jsonpatch.Operation.Move{from: "/a/b", path: "/a/e"}
iex> target = %{"a" => %{"b" => %{"c" => "Bob"}}, "d" => false}
iex> Jsonpatch.Operation.Move.apply_op(move, target)
%{"a" => %{"e" => %{"c" => "Bob"}}, "d" => false}