Jsonpatch v0.6.1 Jsonpatch.Operation.Replace View Source

The replace module helps replacing values in maps and structs by paths.

Link to this section Summary

Functions

Applies an replace operation to a struct/map.

Link to this section Types

Specs

t() :: %Jsonpatch.Operation.Replace{path: String.t(), value: any()}

Link to this section Functions

Link to this function

apply_op(replace, target)

View Source

Specs

apply_op(t(), map()) :: map()

Applies an replace operation to a struct/map.

Examples

iex> add = %Jsonpatch.Operation.Replace{path: "/a/b", value: 1}
iex> target = %{"a" => %{"b" => 2}}
iex> Jsonpatch.Operation.Replace.apply_op(add, target)
%{"a" => %{"b" => 1}}