Jsonpatch v0.6.1 Jsonpatch.Operation.Copy View Source

Represents the handling of JSON patches with a copy operation.

Link to this section Summary

Functions

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

Link to this section Types

Specs

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

Link to this section Functions

Specs

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

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

Examples

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