json-patch / json-patch-tests

Tests for implementations of json-patch
68 stars 21 forks source link

Escape JSON Patch Path for Key with Backslash #42

Closed austince closed 5 years ago

austince commented 5 years ago

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

raymccrae commented 5 years ago

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}]
austince commented 5 years ago

Ah great, thank you for pointing me there!