-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathjsonpath.format.txt
56 lines (42 loc) · 2.7 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
49
50
51
52
53
54
55
56
┏━━━━━━━━━━━━━━┓
┃ JSONPATH ┃
┗━━━━━━━━━━━━━━┛
ALTERNATIVES ==> #See JMESPath doc
VERSION ==> #Only one, from a 2007 blog article
#Is a query language for JSON, inspired from JavaScript
┌───────────┐
│ CHAIN │
└───────────┘
PATH #JSON path
FILTER #Part of JSON path, described below
$ #Root, must be first
\ #Escapes . \ [ * ? @
┌────────────────┐
│ EXPRESSION │
└────────────────┘
PATH['VAR'] #OBJ.VAR. Single quotes only
#VAR follows JSON, e.g. can use \uXXXX or inline Unicode
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[*] but filters by BOOL_EXPR
#Any @ is replaced by each item
#Can be on OBJ|ARR
PATH[(EXPR)] #Like PATH[...] but using a dynamic value
#Any @ is replaced by PATH's value
#EXPR must evaluate to a valid JSON path's filter:
# - anything that can go in [...]
# - i.e. 'VAR', NUM, *, ...,..., ...:...:..., (EXPR), ?(EXPR)
# - all must be STR, except for NUM
# - 'VAR' must have quotes escaped
EXPR #Any expression in the library programming language
#Only one statement