Skip to content

gamache/json_patch_elixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSONPatch

Travis Hex.pm

JSONPatch is an Elixir implementation of the JSON Patch format, described in RFC 6902.

Examples

iex> JSONPatch.patch(%{"a" => 1}, [
...>   %{"op" => "add", "path" => "/b", "value" => %{"c" => true}},
...>   %{"op" => "test", "path" => "/a", "value" => 1},
...>   %{"op" => "move", "from" => "/b/c", "path" => "/c"}
...> ])
{:ok, %{"a" => 1, "b" => %{}, "c" => true}}

iex> JSONPatch.patch(%{"a" => 22}, [
...>   %{"op" => "add", "path" => "/b", "value" => %{"c" => true}},
...>   %{"op" => "test", "path" => "/a", "value" => 1},
...>   %{"op" => "move", "from" => "/b/c", "path" => "/c"}
...> ])
{:error, :test_failed, ~s|test failed (patches[1], %{"op" => "test", "path" => "/a", "value" => 1})|}

Installation

# mix.exs
def deps do
  [
    {:json_patch, "~> 0.8.0"}
  ]
end

Acknowledgements

JSONPatch can be run against the freely available JSON Patch test suite.

Run mix download-tests to install these tests.

Authorship and License

JSONPatch is copyright 2018, Pete Gamache.

JSONPatch is released under the MIT License, available at LICENSE.txt.

About

An Elixir implementation of the JSON Patch format, described in RFC 6902.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages