JSON-Patch
JSON-Patch copied to clipboard
replace incorrectly adds value when target location does not exist
Section 4.3 of RFC6902 says:
The target location MUST exist for the operation to be successful.
But fast-json-patch
incorrectly does an add
instead of failing in this situation:
var fastJsonPatch = require("fast-json-patch")
var document = { foo: "bar" };
var patch = [
{ op: "replace", path: "/biz", value: "baz" },
];
document = fastJsonPatch.applyPatch(document, patch).newDocument;
The result is:
{biz: "baz", foo: "bar"}