Debian Codegraph @

jsonpath-compliance-test-suite/tests/functions/search.json

raw symbols SCIP
1 {
2 "tests": [
3 {
4 "name": "at the end",
5 "selector" : "$[?search(@.a, 'a.*')]",
6 "document" : [{"a": "the end is ab"}],
7 "result": [
8 {"a": "the end is ab"}
9 ]
10 },
11 {
12 "name": "double quotes",
13 "selector" : "$[?search(@.a, \"a.*\")]",
14 "document" : [{"a": "the end is ab"}],
15 "result": [
16 {"a": "the end is ab"}
17 ]
18 },
19 {
20 "name": "at the start",
21 "selector" : "$[?search(@.a, 'a.*')]",
22 "document" : [{"a": "ab is at the start"}],
23 "result": [
24 {"a": "ab is at the start"}
25 ]
26 },
27 {
28 "name": "in the middle",
29 "selector" : "$[?search(@.a, 'a.*')]",
30 "document" : [{"a": "contains two matches"}],
31 "result": [
32 {"a": "contains two matches"}
33 ]
34 },
35 {
36 "name": "regex from the document",
37 "selector" : "$.values[?search(@, $.regex)]",
38 "document" : {"regex": "b.?b", "values": ["abc", "bcd", "bab", "bba", "bbab", "b", true, [], {}]},
39 "result": ["bab", "bba", "bbab"]
40 },
41 {
42 "name": "don't select match",
43 "selector" : "$[?!search(@.a, 'a.*')]",
44 "document" : [{"a": "contains two matches"}],
45 "result": []
46 },
47 {
48 "name": "not a match",
49 "selector" : "$[?search(@.a, 'a.*')]",
50 "document" : [{"a": "bc"}],
51 "result": []
52 },
53 {
54 "name": "select non-match",
55 "selector" : "$[?!search(@.a, 'a.*')]",
56 "document" : [{"a": "bc"}],
57 "result": [{"a": "bc"}]
58 },
59 {
60 "name": "non-string first arg",
61 "selector" : "$[?search(1, 'a.*')]",
62 "document" : [{"a": "bc"}],
63 "result": []
64 },
65 {
66 "name": "non-string second arg",
67 "selector" : "$[?search(@.a, 1)]",
68 "document" : [{"a": "bc"}],
69 "result": []
70 },
71 {
72 "name": "filter, search function, unicode char class, uppercase",
73 "selector": "$[?search(@, '\\\\p{Lu}')]",
74 "document": ["ж", "Ж", "1", "жЖ", true, [], {}],
75 "result": ["Ж", "жЖ"]
76 },
77 {
78 "name": "filter, search function, unicode char class negated, uppercase",
79 "selector": "$[?search(@, '\\\\P{Lu}')]",
80 "document": ["ж", "Ж", "1", true, [], {}],
81 "result": ["ж", "1"]
82 },
83 {
84 "name": "filter, search function, unicode, surrogate pair",
85 "selector": "$[?search(@, 'a.b')]",
86 "document": ["a\uD800\uDD01bc", "abc", "1", true, [], {}],
87 "result": ["a\uD800\uDD01bc"]
88 },
89 {
90 "name": "result cannot be compared",
91 "selector" : "$[?search(@.a, 'a.*')==true]",
92 "invalid_selector": true
93 },
94 {
95 "name": "too few params",
96 "selector" : "$[?search(@.a)]",
97 "invalid_selector": true
98 },
99 {
100 "name": "too many params",
101 "selector" : "$[?search(@.a,@.b,@.c)]",
102 "invalid_selector": true
103 },
104 {
105 "name": "arg is a function expression",
106 "selector" : "$.values[?search(@, value($..['regex']))]",
107 "document" : {
108 "regex": "b.?b",
109 "values": [
110 "abc",
111 "bcd",
112 "bab",
113 "bba",
114 "bbab",
115 "b",
116 true,
117 [],
118 {}
119 ]
120 },
121 "result": ["bab", "bba", "bbab"]
122 }
123 ]
124 }