jsondiffpatch.net
jsondiffpatch.net copied to clipboard
`~` and `/` show be replaced in patch path
As rfc6901#section-3 documented, we should replace ~
with ~0
and replace /
with ~1
.
This is Also the problem I encounted when trying to patch k8s resources, error message: the server rejected our request due to an error in our request
.
Json Patch
A JSON Pointer is a Unicode string (see [RFC4627], Section 3) containing a sequence of zero or more reference tokens, each prefixed by a '/' (%x2F) character.
Because the characters '~' (%x7E) and '/' (%x2F) have special meanings in JSON Pointer, '~' needs to be encoded as '~0' and '/' needs to be encoded as '~1' when these characters appear in a reference token.
Agreed, this is causing a bug in my use case where users legitimately enter values including a '/'.