This repository was archived by the owner on Jul 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path5-extract-from-object.json
102 lines (102 loc) · 5.6 KB
/
5-extract-from-object.json
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{
"data": {
"number": 1, "string": "A", "array": [2, 3, 4],
"object": { "number": 11, "string": "AA", "array": [12, 13, 14] },
"objectArray": [
{ "type": "X", "number": 101, "string": "AAA", "array": [102, 103, 104] },
{ "type": "Y", "number": 201, "string": "AAB", "array": [202, 203, 204] },
{ "type": "Y", "number": 301, "string": "AAC", "array": [302, 303, 304] },
{ "type": "Y", "number": 401, "string": "AAD", "array": [402, 403, 404] }
],
"deepArray": [[[[[{ "number": 1001, "string": "AAAA", "array": [1002, 1003, 1004] }]]]]],
"deepObjectArray": [{ "type": "X" }, { "type": "Y", "number": 10001, "objectArray": [{ "type": "X" }, { "type": "Y", "number": 10002 }] }],
"$STRING": "B",
"a field": "C",
"a.field": "D",
"abc 123 . () [] {} <>": "E",
"true": "F",
"false": "G",
"null": "H"
},
"testCases": [
["number", 1],
["-number", -1],
["string", "A"],
["array", [2, 3, 4]],
["array[0]", 2],
["array[1]", 3],
["array[-1]", 4],
["object", { "number": 11, "string": "AA", "array": [12,13,14] }],
["object['number']", 11],
["object.number", 11],
["object.string", "AA"],
["object.array", [12, 13, 14]],
["object.array[0]", 12],
["object.array[1]", 13],
["object.array[-1]", 14],
["objectArray.find(type == 'Y')", { "type": "Y", "number": 201, "string": "AAB", "array": [202, 203, 204] }],
["objectArray.find(type == 'Y')['number']", 201],
["objectArray.find(type == 'Y').number", 201],
["objectArray.find(type == 'Y').string", "AAB"],
["objectArray.find(type == 'Y').array", [202, 203, 204]],
["objectArray.find(type == 'Y').array[0]", 202],
["objectArray.find(type == 'Y').array[1]", 203],
["objectArray.find(type == 'Y').array[-1]", 204],
["objectArray.filter(type == 'Y')[0]", { "type": "Y", "number": 201, "string": "AAB", "array": [202, 203, 204] }],
["objectArray.filter(type == 'Y')[0]['number']", 201],
["objectArray.filter(type == 'Y')[0].number", 201],
["objectArray.filter(type == 'Y')[0].string", "AAB"],
["objectArray.filter(type == 'Y')[0].array", [202, 203, 204]],
["objectArray.filter(type == 'Y')[0].array[0]", 202],
["objectArray.filter(type == 'Y')[0].array[1]", 203],
["objectArray.filter(type == 'Y')[0].array[-1]", 204],
["objectArray.filter(type == 'Y')[1]", { "type": "Y", "number": 301, "string": "AAC", "array": [302, 303, 304] }],
["objectArray.filter(type == 'Y')[1]['number']", 301],
["objectArray.filter(type == 'Y')[1].number", 301],
["objectArray.filter(type == 'Y')[1].string", "AAC"],
["objectArray.filter(type == 'Y')[1].array", [302, 303, 304]],
["objectArray.filter(type == 'Y')[1].array[0]", 302],
["objectArray.filter(type == 'Y')[1].array[1]", 303],
["objectArray.filter(type == 'Y')[1].array[-1]", 304],
["objectArray.filter(type == 'Y')[-1]", { "type": "Y", "number": 401, "string": "AAD", "array": [402, 403, 404] }],
["objectArray.filter(type == 'Y')[-1]['number']", 401],
["objectArray.filter(type == 'Y')[-1].number", 401],
["objectArray.filter(type == 'Y')[-1].string", "AAD"],
["objectArray.filter(type == 'Y')[-1].array", [402, 403, 404]],
["objectArray.filter(type == 'Y')[-1].array[0]", 402],
["objectArray.filter(type == 'Y')[-1].array[1]", 403],
["objectArray.filter(type == 'Y')[-1].array[-1]", 404],
["objectArray.filter(type == 'Y').map(number)", [201, 301, 401]],
["objectArray.filter(type == 'Y').map(['number'])", [201, 301, 401]],
["objectArray.filter(type == 'Y').map(string)", ["AAB", "AAC", "AAD"]],
["objectArray.filter(type == 'Y').map(array)", [[202, 203, 204], [302, 303, 304], [402, 403, 404]]],
["objectArray.filter(type == 'Y').map(array[0])", [202, 302, 402]],
["objectArray.filter(type == 'Y').map(array[1])", [203, 303, 403]],
["objectArray.filter(type == 'Y').map(array[-1])", [204, 304, 404]],
["objectArray.filter(array[0] == 102)[0].number", 101],
["objectArray.filter(type == $.deepObjectArray[0].type)[0].number", 101],
["deepArray[0][-1][0][-1][0]", { "number": 1001, "string": "AAAA", "array": [1002, 1003, 1004] }],
["deepArray[0][-1][0][-1][0]['number']", 1001],
["deepArray[0][-1][0][-1][0].number", 1001],
["deepArray[0][-1][0][-1][0].string", "AAAA"],
["deepArray[0][-1][0][-1][0].array", [1002, 1003, 1004]],
["deepArray[0][-1][0][-1][0].array[0]", 1002],
["deepArray[0][-1][0][-1][0].array[1]", 1003],
["deepArray[0][-1][0][-1][0].array[-1]", 1004],
["deepObjectArray.filter(type == 'Y')[0].objectArray.filter(type == 'Y')[0].number", 10002],
["deepObjectArray.filter(type == 'Y' && objectArray.filter(type == 'Y')[0].number == 10002)[0].number", 10001],
["array[0] + array[1]", 5],
["array[0] == 2 ? 'X' : (array[0] == 3 ? 'Y' : 'Z')", "X"],
["array[1] == 2 ? 'X' : (array[1] == 3 ? 'Y' : 'Z')", "Y"],
["array[2] == 2 ? 'X' : (array[2] == 3 ? 'Y' : 'Z')", "Z"],
["objectArray.filter(type == 'Y')[0].string + objectArray.filter(type == 'Y')[1].string", "AABAAC"],
["$STRING", "B"],
["['$STRING']", "B"],
["['a field']", "C"],
["['a.field']", "D"],
["['abc 123 . () [] {} <>']", "E"],
["['true']", "F"],
["['false']", "G"],
["['null']", "H"]
]
}