1
+ ; This file is parsed to generate the specification included in the website
1
2
; Double semicolons (;;) at the beginning of a line represent documentation in markdown format for the preceding rule
2
3
; intended for inclusion in the html version of the specification.
3
4
; Double semicolons inline with a rule represent an alternative header to use when rendering markdown. This can optionally
4
5
; include a trailing '\' to indicate that it is to be included with the documentation of the following rule.
5
6
6
- ;; # JMESPath Specification
7
- ;;
8
- ;; This document describes the specification for jmespath.
9
- ;;
10
- ;; If you'd like an introduction to the JMESPath language, see the JMESPath Tutorial and the JMESPath Examples page.
11
- ;;
12
- ;; In the specification, examples are shown through the use of a search function. The syntax for this function is:
7
+ ;; In this specification, examples are shown through the use of a search function. The syntax for this function is:
13
8
;;
14
9
;; ```
15
10
;; search(<jmespath expr>, <JSON document>) -> <return value>
33
28
;; - object (an unordered collection of key value pairs)
34
29
;; - null
35
30
;;
36
- ;; Expression types are discussed in the Functions Expressions section.
31
+ ;; Expression types are discussed in the [Function Expressions](#function-expressions) section.
37
32
;;
38
33
;; Implementations can map the corresponding JSON types to their language equivalent. For example, a JSON null could map to
39
34
;; None in python, and nil in ruby and go.
49
44
;; - and: &&
50
45
;; - unary not: !
51
46
;; - rbracket: ]
47
+ ;;
48
+ ;; %%GRAMMAR%%
52
49
53
50
expression = sub-expression / index-expression / comparator-expression / list-filter-expr
54
51
expression =/ or-expression / identifier
55
52
expression =/ and-expression / not-expression / paren-expression
56
53
expression =/ multi-select-list / multi-select-hash / literal
57
54
expression =/ function-expression / pipe-expression / raw-string
58
55
expression =/ current-node
59
- sub-expression = expression "." ( identifier / multi-select-list / multi-select-hash / function-expression / "*" ) ;; # SubExpressions
60
- ;; A subexpression is a combination of two expressions separated by the '.' char. A subexpression is evaluated as follows:
56
+ sub-expression = expression "." ( identifier / multi-select-list / multi-select-hash / function-expression / "*" ) ;; # Sub-expressions
57
+ ;; A sub-expression is a combination of two expressions separated by the '.' char. A sub-expression is evaluated as follows:
61
58
;;
62
59
;; - Evaluate the expression on the left with the original JSON document.
63
60
;; - Evaluate the expression on the right with the result of the left expression evaluation.
@@ -67,7 +64,7 @@ sub-expression = expression "." ( identifier / multi-select-list / multi-sele
67
64
;; left-evaluation = search(left-expression, original-json-document)
68
65
;; result = search(right-expression, left-evaluation)
69
66
;; ```
70
- ;; A subexpression is itself an expression, so there can be multiple levels of subexpressions : grandparent.parent.child.
67
+ ;; A sub-expression is itself an expression, so there can be multiple levels of sub-expressions : grandparent.parent.child.
71
68
;; Examples
72
69
;;
73
70
;; Given a JSON document: ``{"foo": {"bar": "baz"}}``, and a jmespath expression: foo.bar, the evaluation process would be:
@@ -202,7 +199,7 @@ not-expression = "!" expression ;; # Not Expressions
202
199
;; search(!EmptyList, {"EmptyList": []}) -> true
203
200
;; ```
204
201
205
- paren-expression = "(" expression ")" ;; # Paren Expressions
202
+ paren-expression = "(" expression ")" ;; # Parenthetical Expressions
206
203
;; A paren-expression allows a user to override the precedence order of an expression, e.g. (a || b) && c.
207
204
;;
208
205
;; ## Examples
@@ -439,7 +436,7 @@ comparator = "<" / "<=" / "==" / ">=" / ">" / "!="
439
436
;; search(foo[?a==b], {"foo": [{"a": 1, "b": 2}, {"a": 2, "b": 2}]}) -> [{"a": 2, "b": 2}]
440
437
;; ```
441
438
442
- function-expression = unquoted-string ( no-args / one-or-more-args ) ;; # Functions Expressions \
439
+ function-expression = unquoted-string ( no-args / one-or-more-args ) ;; # Function Expressions \
443
440
no-args = "(" ")" ;; \
444
441
one-or-more-args = "(" ( function-arg *( "," function-arg ) ) ")" ;; \
445
442
function-arg = expression / expression-type ;; \
@@ -539,13 +536,14 @@ raw-string-escape = escape ("'" / escape)
539
536
;; - Not expanding tab characters or any other escape sequences documented in RFC 4627 section 2.5.
540
537
;;
541
538
;; ## Examples
542
- ;;
539
+ ;; ```
543
540
;; search('foo', "") -> "foo"
544
541
;; search(' bar ', "") -> " bar "
545
542
;; search('[baz]', "") -> "[baz]"
546
543
;; search('[baz]', "") -> "[baz]"
547
544
;; search('\u03a6', "") -> "\u03a6"
548
545
;; search('\\', "") -> "\\"
546
+ ;; ```
549
547
550
548
literal = "`" json-value "`" ;; # Literal Expressions
551
549
;; A literal expression is an expression that allows arbitrary JSON objects to be specified. This is useful in filter
0 commit comments