Repository navigation
Expand file tree
/
Copy pathcurrent_key_identifier.json
More file actions
61 lines (61 loc) · 1.9 KB
/
Copy pathcurrent_key_identifier.json
File metadata and controls
61 lines (61 loc) · 1.9 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
{
"tests": [
{
"name": "current key of an object",
"selector": "$.some[?match(#, '^b.*')]",
"document": {
"some": { "foo": "a", "bar": "b", "baz": "c", "qux": "d" }
},
"result": ["b", "c"],
"result_paths": ["$['some']['bar']", "$['some']['baz']"]
},
{
"name": "current key of an array",
"selector": "$.some[?# > 1]",
"document": { "some": ["other", "thing", "foo", "bar"] },
"result": ["foo", "bar"],
"result_paths": ["$['some'][2]", "$['some'][3]"]
},
{
"name": "current key of a string selects nothing",
"selector": "$.some[?# > 1]",
"document": { "some": "thing" },
"result": [],
"result_paths": []
},
{
"name": "current key of an object",
"selector": "$.some[?match(#, '^b.*')]",
"document": {
"some": { "foo": "a", "bar": "b", "baz": "c", "qux": "d" }
},
"result": ["b", "c"],
"result_paths": ["$['some']['bar']", "$['some']['baz']"],
"tags": ["extra"]
},
{
"name": "current key of an array",
"selector": "$.some[?# > 1]",
"document": { "some": ["other", "thing", "foo", "bar"] },
"result": ["foo", "bar"],
"result_paths": ["$['some'][2]", "$['some'][3]"],
"tags": ["extra"]
},
{
"name": "current key identifier, match on object names",
"selector": "$[?match(#, '^ab.*') && length(@) > 0 ]",
"document": { "abc": [1, 2, 3], "def": [4, 5], "abx": [6], "aby": [] },
"result": [[1, 2, 3], [6]],
"result_paths": ["$['abc']", "$['abx']"],
"tags": ["extra"]
},
{
"name": "current key identifier, compare current array index",
"selector": "$.abc[?(# >= 1)]",
"document": { "abc": [1, 2, 3], "def": [4, 5], "abx": [6], "aby": [] },
"result": [2, 3],
"result_paths": ["$['abc'][1]", "$['abc'][2]"],
"tags": ["extra"]
}
]
}