Closed norpan closed 8 months ago
Describe the bug According to the jsonpath tests, it should be possible to replace the whole document using the path "".
To Reproduce Jsonpatch.apply_patch([%{"op" => "replace", "path" => "", "value" => %{"baz" => "qux"}}], %{"foo" => "bar"})
Jsonpatch.apply_patch([%{"op" => "replace", "path" => "", "value" => %{"baz" => "qux"}}], %{"foo" => "bar"})
Result
{:error, %Jsonpatch.Error{ patch: %{"op" => "replace", "path" => "", "value" => %{"baz" => "qux"}}, patch_index: 0, reason: {:invalid_path, ""} }}
Expected behavior {:ok, %{"baz" => "qux"}}
{:ok, %{"baz" => "qux"}}
Additional context Latest tests can be found at https://github.com/json-patch/json-patch-tests/blob/master/tests.json
Hey @norpan , thx for submitting the issue. That revealed some edge cases.
Thanks for the quick reply and fix!
Describe the bug According to the jsonpath tests, it should be possible to replace the whole document using the path "".
To Reproduce
Jsonpatch.apply_patch([%{"op" => "replace", "path" => "", "value" => %{"baz" => "qux"}}], %{"foo" => "bar"})
Result
Expected behavior
{:ok, %{"baz" => "qux"}}
Additional context Latest tests can be found at https://github.com/json-patch/json-patch-tests/blob/master/tests.json