-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathparent.js
36 lines (35 loc) · 956 Bytes
/
parent.js
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
import { JSONPath } from 'jsonpath-plus';
import objectScan from '../../../src/index.js';
export default {
_name: 'Get Parent',
_fixture: 'cond',
_result: [
{ x: 'no', y: 1 },
{ x: 'no', y: 1 },
[{ x: 'no', y: 1 }],
{ a: [{ x: 'yes', y: 2 }], b: [{ x: 'no', y: 1 }] },
{ x: 'yes', y: 2 },
{ x: 'yes', y: 2 },
[{ x: 'yes', y: 2 }],
{ a: [{ x: 'yes', y: 2 }], b: [{ x: 'no', y: 1 }] }
],
objectScanCompiled: objectScan(['**'], {
rtn: 'parent'
}),
objectScan: (v) => objectScan(['**'], {
rtn: 'parent'
})(v),
jsonpathplus: {
fn: (v) => JSONPath({ path: '$..*', json: v, resultType: 'parent' }),
result: [
{ a: [{ x: 'yes', y: 2 }], b: [{ x: 'no', y: 1 }] },
{ a: [{ x: 'yes', y: 2 }], b: [{ x: 'no', y: 1 }] },
[{ x: 'yes', y: 2 }],
{ x: 'yes', y: 2 },
{ x: 'yes', y: 2 },
[{ x: 'no', y: 1 }],
{ x: 'no', y: 1 },
{ x: 'no', y: 1 }
]
}
};