Closed cmannett85 closed 6 years ago
Thanks for noting! I could fix this issue by implementing the copy operation similar to the move operation:
const std::string from_path = get_value("copy", "from", true);
const json_pointer from_ptr(from_path);
// the "from" location must exist - use at()
basic_json v = result.at(from_ptr);
// The copy is functionally identical to an "add"
// operation at the target location using the value
// specified in the "from" member.
operation_add(ptr, v);
I was just about to commit the change when I realized the library currently fails some tests from https://github.com/json-patch/json-patch-tests - some even trigger assertions. I shall have a look at these failing tests and see if I can fix these problems as well.
Thanks for the rapid response!
The test suite revealed another problem: we did not check if we completely parsed an array index. For instance, /array/1
and /array/1e
were treated the same way.
@cmannett85 Could you check whether the develop
branch works for you?
Using my trivial example above, I now get:
Move: 403
Copy: 403
Which is expected - thank you!
The above "move" and "copy" JSON patch operations are both invalid for the same reason:
/a/b/c
is an invalid path becauseb
does not already exist - however, the "copy" succeeds.Legalise: RFC6902 4.5:
RFC6092 4.1: