-
Notifications
You must be signed in to change notification settings - Fork 16
/
jsonpath.format.txt
48 lines (36 loc) · 3.17 KB
/
jsonpath.format.txt
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
JSONPATH
VERSION ==> #Only one, from a 2007 blog article
#Is a query language for JSON, inspired from JavaScript
PATH #JSON path
FILTER #Part of JSON path, described below
$ #Root, must be first
PATH['VAR'] #OBJ.VAR. Single quotes only
PATH[NUM] #ARR[NUM]
PATH[*] #OBJ|ARR.*
PATH.VAR
PATH.NUM
PATH.* #Same as PATH['VAR'|NUM|*]
PATH..FILTER
PATH..[FILTER] #OBJ|ARR.**.FILTER. Includes each descendant, not only the furthest ones.
PATH[FILTER,...] #Or|union. FILTER can be 'VAR', NUM or [...:...:...]
#No duplicates
PATH[[NUM]:[NUM2][:STEP]] #ARR from NUM to NUM2 (excluded) (def: end)
#NUM[2] can be negative for "from end"
#STEP can be negative
PATH[(EXPR)] #Like PATH[...]:
# - ... is replaced by result of EXPR:
# - any expression in the library programming language
# - there can be 0, 1 or several @
# - @ are replaced by PATH's value
# - only one statement
# - ... must be valid JSON path's filter:
# - anything that can go in [...]
# - i.e. 'VAR', NUM, *, [...,...], [...:...:...] or even another (EXPR) or ?(EXPR)
# - all must be STR, except for NUM
# - 'VAR' must have quotes escaped
PATH[?(EXPR)] #Like PATH[*] but:
# - only keep elements that evaluates to true when EXPR applied
# - EXPR is like above, except @ are replaced by each of those elements
#Can be on OBJ|ARR