json-patch
json-patch copied to clipboard
EnsurePathExistsOnAdd not working with escaped slash
When escaping a slash with ~1 the following error is printed when trying to add a nested path and using ensurePathExistsOnAdd:
patch_test.go:831: Unable to apply patch: add operation does not apply: doc is missing path: "/with~1slash/nested": missing value
The first test works, the second one fails:
{
`{ "foo": ["bar"]}`,
`[ { "op": "add", "path": "/with~1slash", "value": "bar" } ]`,
`{ "foo": ["bar"], "with/slash": "bar"}`,
true,
true,
},
{
`{ "foo": ["bar"]}`,
`[ { "op": "add", "path": "/with~1slash/nested", "value": "bar" } ]`,
`{ "foo": ["bar"], "with/slash": { "nested": "bar"}}`,
true,
true,
},