Skip to content

Commit 1d9ff9f

Browse files
committed
Documented the $ root-node token.
1 parent 9ea4bc0 commit 1d9ff9f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

GRAMMAR.ABNF

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,3 +657,39 @@ int = zero / ( digit1-9 *digit )
657657
minus = %x2D ; -
658658
plus = %x2B ; +
659659
zero = %x30 ; 0
660+
661+
expression =/ root-node ;; ## Root Reference
662+
663+
root-node = "$"
664+
665+
;; ## root-node
666+
;;
667+
;; The `root-node` token can be used to represent the original input JSON document.
668+
;;
669+
;; As a JMESPath expression is being evaluated, the current scope changes.
670+
;; Given a simple sub expression such as `foo.bar`, first the `foo` expression is evaluated
671+
;; with the starting input JSON document, and the result of that expression is then used as
672+
;; the current scope when the `bar` element is evaluated.
673+
;;
674+
;; Once we’ve drilled down to a specific scope, the `root-node` token can be used
675+
;; to refer to the original JSON document.
676+
;;
677+
;; Example
678+
;;
679+
;; Given a JSON document:
680+
;;
681+
;; ```json
682+
;; {
683+
;; "first_choice": "WA",
684+
;; "states": [
685+
;; {"name": "WA", "cities": ["Seattle", "Bellevue", "Olympia"]},
686+
;; {"name": "CA", "cities": ["Los Angeles", "San Francisco"]},
687+
;; {"name": "NY", "cities": ["New York City", "Albany"]}
688+
;; ]
689+
;; }
690+
;; ```
691+
;; We can retrieve the list of cities of the state corresponding to the `first_choice` key
692+
;; using the following expression:
693+
;;
694+
;; ` states[? name == $.first_choice ].cities[] `
695+
;;

0 commit comments

Comments
 (0)