jora
jora copied to clipboard
.. operator doesn't work as expected (based on prior art)
Continued from discoveryjs/browser-extension-json-discovery#68.
Example
JSON
{
"one": {
"one" : 1,
"two" : 2
},
"two": {
"one" : 3,
"two" : 4
}
}
Filter As Tested
..one
Current Workaroud
($ + ..values()).one
Result
Expected:
Like $..one in JSONPath or ..|.one? in jq (playgrounds linked):
[
{
"one": 1,
"two": 2
}, // .one
1, // .one.one
3 // .two.one
]
query..subquery returns the query filtered by the subquery and recursively applies the filter to each child. (See use cases below.)
Actual:
[
{
"one": 1,
"two": 2
}, // .one
1 // .one.one
]
query..subquery returns the query filtered by the subquery and recursively applies the filter to each result. (I'm curious about potential use cases.)
Use Cases
Save Typing
Example: ..isarray vs .dependencies.isarray
Quickly find an item (especially using the browser extension) without traversing its parent hierarchy.
Traverse Recursive Schemas
Example: ..isobject vs ..values().isobject
Find an item that may appear arbitrarily deep (dependencies have dependencies have dependencies and so on).
Align with Prior Art
The .. operator has a history (documentation linked):
Is this open to change? I still have to reference this topic to explore JSON in JsonDicovery (which I love otherwise). It's just unintuitive to dig arbitrarily deep into a tree which is what I usually want to accomplish.
Annual ping for shorthand syntax 🙏🏼