-
Notifications
You must be signed in to change notification settings - Fork 15
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
Lookup in deeply nested JSON, an abbreviated syntax for map:find #297
Comments
This is essentially a duplicate for issue #262, and I propose to close it as such. There's no point in having a shorthand for |
But #262 is about a function, and this is about a syntax map:find is bad, because it is too verbose. map:search is even more verbose. From the 262 example, And you can use this syntax to do things map:find cannot do. With Sometimes JSON documents have optional arrays. The document is either Sometimes JSON documents do not use keys, but string ids. Like rather than writing |
I more and more like the idea of introducing an operator for descendant lookups. It’s true that ($map?root => map:find('items') => map:find('names'))[map:find(., 'id') = '123'] vs. $map?root??items??names[??id = '123'] It’s also true that there’s currently no way to access siblings and ancestors. On the other hand, most lookups in practice are forward-only, and many others can be rewritten. I still believe that I had similar thoughts some time ago before I proposed |
If the changes suggested in issue #334 are made, then the |
Reading the proposal again, I see one might allow |
Incorporated in the spec, can be closed. |
In XML, you can select all X nodes with an abbreviated syntax //X
There is no abbreviated syntax for JSON
I propose to add a ?? syntax. Like / is doubled for //, it doubles the ? lookup operator.
The syntax is basically the same as for ?:
[200] UnaryLookupRecursion ::= "??" KeySpecifier
[143] LookupRecursion ::= "??" KeySpecifier
[144] KeySpecifier |::= NCName | IntegerLiteral | StringLiteral | VarRef | ParenthesizedExpr | "*"
For the semantic it can call map:find, except for * and varref:
Unary variant:
Postfix variant:
E??S
would beE!??S
if it is atomic, orlet $s := data(S) return E!??$s
if S is parenthesizedThis probably conflicts with #171
The text was updated successfully, but these errors were encountered: