JSON Patch

https://jsonpatch.com/

35 points · 2 comments · view on lemmy.world

2 Comments

homo_ignotus@programming.dev · 9 pts · 2y

Why use JSON Pointer? We already have structured data (JSON), so what's wrong with ["biscuits", 0, "name"] instead of "biscuits/0/name"? This sidesteps the escaping problem.

And the reason is clearly not brevity, given the rest of the spec.

Deebster@programming.dev · 8 pts · 2y

If you need to refer to a key with ~ or / in its name, you must escape the characters with 0 and 1 respectively. For example, to get "baz" from { "foo/bar": "baz" } you’d use the pointer /foo1bar~0.

I guess they're using ~ for escaping since backslash is already escaping text content, not that you'd see it very often in keys.

Having magic values instead of using ~~ and ~/ feels ugly.