2 ms·
Escaping is weird. Why ~0 and ~1 instead of \ and \\ ? Also > Finally, if you need to refer to the end of an array you can use - instead of an index. For examp
by ajuc 4y ago
Escaping is weird. Why ~0 and ~1 instead of \ and \\ ? Also
> Finally, if you need to refer to the end of an array you can use - instead of an index. For example, to refer to the end of the array of biscuits above you would use /biscuits/-
how do you refer to "this value" in this example?
{
"biscuits": {
"-": "this value"
"zzzz": "something else"
}
}
- hombre_fatal 4y ago"/biscuits/-" addresses "this value" because biscuits is not an array. If you check out the implementations at the bottom of the post, you'll see that, at runtime, if biscuits is an object they index into `obj["-"]`. And if it's an array, they special-case "-" and index into `array[length]`.
- chii 4y agoso the spec has implementation specific behavior that's not fully specified by just the spec? i rather see they implement jsonpath - https://tools.ietf.org/id/draft-goessner-dispatch-jsonpath-00.html https://tools.ietf.org/id/draft-goessner-dispatch-jsonpath-0... instead of inventing their own xpath-like expression language tbh. Edit: i suppose i shouldn't be surprised there's multiple standards to varying degrees of acceptance: https://datatracker.ietf.org/doc/html/rfc6901 https://datatracker.ietf.org/doc/html/rfc6901 so may be it is fine to use this expression language...
- chrisoverzero 4y ago> so the spec has implementation specific behavior […] No, that’s specified in the JSON Pointer spec, which this spec depends on: https://datatracker.ietf.org/doc/html/rfc6901 https://datatracker.ietf.org/doc/html/rfc6901 > […] that's not fully specified by just the spec? Specs depend on previous specs nearly all the time. Thank goodness for hyperlinks.
- hombre_fatal 4y agoI didn't mean to say that all there was were reference impls. I just clicked through the impls to quickly answer your question out of curiosity instead of scanning an RFC. It also shows this in the Pointer spec.
- masklinn 4y ago> Escaping is weird. Why ~0 and ~1 instead of \ and \\ ? Possibly because JSON already has them, so you need to further escape the escapes, which is difficult to author and read?