Repository navigation
Expand file tree
/
Copy pathkeys_selector.json
More file actions
78 lines (78 loc) · 2.11 KB
/
Copy pathkeys_selector.json
File metadata and controls
78 lines (78 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
"tests": [
{
"name": "keys from an object",
"selector": "$.some[~]",
"document": { "some": { "other": "foo", "thing": "bar" } },
"result": ["other", "thing"],
"result_paths": ["$['some'][~'other']", "$['some'][~'thing']"],
"tags": ["extra"]
},
{
"name": "shorthand keys from an object",
"selector": "$.some.~",
"document": { "some": { "other": "foo", "thing": "bar" } },
"result": ["other", "thing"],
"result_paths": ["$['some'][~'other']", "$['some'][~'thing']"],
"tags": ["extra"]
},
{
"name": "keys from an array",
"selector": "$.some[~]",
"document": { "some": ["other", "thing"] },
"result": [],
"result_paths": [],
"tags": ["extra"]
},
{
"name": "shorthand keys from an array",
"selector": "$.some.~",
"document": { "some": ["other", "thing"] },
"result": [],
"result_paths": [],
"tags": ["extra"]
},
{
"name": "recurse object keys",
"selector": "$..~",
"document": { "some": { "thing": "else", "foo": { "bar": "baz" } } },
"result": ["some", "thing", "foo", "bar"],
"result_paths": [
"$[~'some']",
"$['some'][~'thing']",
"$['some'][~'foo']",
"$['some']['foo'][~'bar']"
],
"tags": ["extra"]
},
{
"name": "object key",
"selector": "$.a[0].~",
"document": { "a": [{ "b": "x", "c": "z" }, { "b": "y" }] },
"result": ["b", "c"],
"result_paths": ["$['a'][0][~'b']", "$['a'][0][~'c']"],
"tags": ["extra"]
},
{
"name": "array key",
"selector": "$.a.~",
"document": { "a": [{ "b": "x", "c": "z" }, { "b": "y" }] },
"result": [],
"result_paths": [],
"tags": ["extra"]
},
{
"name": "descendant keys",
"selector": "$..[~]",
"document": { "a": [{ "b": "x", "c": "z" }, { "b": "y" }] },
"result": ["a", "b", "c", "b"],
"result_paths": [
"$[~'a']",
"$['a'][0][~'b']",
"$['a'][0][~'c']",
"$['a'][1][~'b']"
],
"tags": ["extra"]
}
]
}