-
Notifications
You must be signed in to change notification settings - Fork 0
Escaping Syntax #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The double slash feels similarly weird. I wish for JSON Patch 2 to allow having arrays as paths, circumventing the problem of escaping and making it much faster for machines to parse the path. For instance, It is backwards-compatible, as libraries can detect whether the path is a string or an array. |
The escape syntax is well-established from JSON Pointer. Why are we looking to deviate?
JSON Path is a query syntax that has the potential to return multiple results. Many use cases for JSON Patch require a single result, for which JSON Pointer is much more well-suited. The only time I could see wanting JSON Path is for when we explicitly want potentially multiple matches (like a SQL (See also #23) I agree with support for arrays as an option, however. |
+1 for using as array Array syntax is very useful for operations which are semantically very different for objects and arrays. For example "insert" operation is very different for objects and arrays, in object simply a new key is inserted, but in arrays all elements past insertion point are shifted. When using an array as the path one can infer that if path step is a number it is indexing an array, if it is a string, it is referencing a key in object. That information is useful when doing operational transformation, when you need to transform one operation agains the other. Now if we use Json Pointer you basically need to see if the key step looks like a number, then it is likely that it is indexing an array and then one, kinda, can do the operational transform assuming the pointer is referencing an array, but it could also be completely wrong, if in reality the pointer is referencing an object with a key that looks like a number. FWIW, Slate.js is using and array as a pointer. |
(from an RFC Errata)
The escape syntax seems weird and confusing. Rather than ~0 and ~1, why not use a repeated (double) slash to escape a slash? This is similar to how SQL escapes single quotes in string literals by using the single quote twice.
We have JSON functions in Presto (prestodb.io) that could benefit from an improved syntax (they currently use JSONPath), but I can't see understanding ~0 and ~1.
The text was updated successfully, but these errors were encountered: