json-patch/json-patch-tests

Escape JSON Patch Path for Key with Backslash

austince opened this issue · 2 comments

How would one create the object { "valid/key": true } with JSON Patch? I can't find anything in the RFC.

JSON Patch uses JSON Pointers to specify the path to elements of the JSON document. The answer you're looking for is documented in RFC6901, section 3. "~"(tilde) is encoded as "~0" and "/"(forward slash) is encoded as "~1".

[{"op": "add",  "path": "/valid~1key", "value": true}]

Ah great, thank you for pointing me there!