-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Continued from discoveryjs/JsonDiscovery#68.
Example
JSON
{
"one": {
"one" : 1,
"two" : 2
},
"two": {
"one" : 3,
"two" : 4
}
}Filter As Tested
..oneCurrent Workaroud
($ + ..values()).oneResult
Expected:
Like $..one in JSONPath or ..|.one? in jq (playgrounds linked):
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):
Metadata
Metadata
Assignees
Labels
No labels
[ { "one": 1, "two": 2 }, // .one 1, // .one.one 3 // .two.one ]