diff --git a/docs/index.html b/docs/index.html index 7a6c058c..743f636f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -9,7 +9,7 @@ @@ -1157,7 +1157,7 @@ Normington, et al. -Expires 21 May 2021 +Expires 30 May 2021 [Page] @@ -1170,12 +1170,12 @@
draft-normington-jsonpath-latest
Published:
- +
Intended Status:
Standards Track
Expires:
-
+
Authors:
@@ -1198,7 +1198,7 @@

JavaScript Object Notation (JSON) Path

Abstract

-

JSON Path defines a string syntax for identifying values +

JSONPath defines a string syntax for identifying values within a JavaScript Object Notation (JSON) document.

@@ -1224,7 +1224,7 @@

time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

- This Internet-Draft will expire on 21 May 2021.

+ This Internet-Draft will expire on 30 May 2021.

-
+
-

-2. JSON Path Syntax and Semantics +

+2. JSONPath Syntax and Semantics

2.1. Overview

-

A JSON Path is a string which selects zero or more nodes of any JSON document. -A valid JSON Path conforms to the ABNF syntax defined by this document.

-

A JSON Path MUST be encoded using UTF-8. To parse a JSON Path according to +

A JSONPath is a string which selects zero or more nodes of a piece of JSON. +A valid JSONPath conforms to the ABNF syntax defined by this document.

+

A JSONPath MUST be encoded using UTF-8. To parse a JSONPath according to the grammar in this document, its UTF-8 form SHOULD first be decoded into Unicode code points as described in [RFC3629].

@@ -1397,8 +1397,7 @@

2.2. Terminology

-

A JSON document is logically a tree of nodes with the document as the root -node of the tree.

+

A JSON value is logically a tree of nodes.

Each node holds a JSON value (as defined by [RFC8259]) of one of the types object, array, number, string, or one of the literals true, false, or null. @@ -1412,23 +1411,23 @@

2.3. Implementation

An implementation of this specification, from now on referred to simply as -"an implementation", SHOULD takes two inputs, a JSON Path and a JSON document, +"an implementation", SHOULD takes two inputs, a JSONPath and a JSON value, and produce -a possibly empty list of nodes of the JSON document which are selected by -the JSON Path or an error (but not both).

+a possibly empty list of nodes of the JSON value which are selected by +the JSONPath or an error (but not both).

If no node is selected and no error has occurred, an implementation MUST return an empty list of nodes.

-

Syntax errors in the JSON Path SHOULD be detected before selection is attempted -since these errors do not depend on the JSON document. -Therefore, an implementation SHOULD take a JSON Path and produce an optional +

Syntax errors in the JSONPath SHOULD be detected before selection is attempted +since these errors do not depend on the JSON value. +Therefore, an implementation SHOULD take a JSONPath and produce an optional syntax error and then, -if and only if an error was not produced, SHOULD take a JSON document and +if and only if an error was not produced, SHOULD take a JSON value and produce a list of nodes or an error (but not both).

-

Alternatively, an implementation MAY take a JSON Path and a JSON document +

Alternatively, an implementation MAY take a JSONPath and a JSON value and produce a list of nodes or an optional error (but not both).

-

For any implementation, if a syntactically invalid JSON Path is provided, +

For any implementation, if a syntactically invalid JSONPath is provided, the implementation MUST return an error.

-

If a syntactially invalid JSON document is provided, any implementation SHOULD +

If a syntactially invalid JSON value is provided, any implementation SHOULD return an error.

@@ -1437,8 +1436,8 @@

2.4. Syntax

-

Syntactically, a JSON Path consists of a root selector ($), which -selects the root node of a JSON document, followed by a possibly empty +

Syntactically, a JSONPath consists of a root selector ($), which +selects the root node of a JSON value, followed by a possibly empty sequence of selectors.

@@ -1465,10 +1464,10 @@ 

simply result in fewer nodes being selected.

But a selector doesn't just act on a single node: each selector acts on a list of nodes and produces a list of nodes, as follows.

-

After the root selector, the remainder of the JSON Path is processed by passing +

After the root selector, the remainder of the JSONPath is processed by passing lists of nodes from one selector to the next ending up with a list of nodes which is the result of -applying the JSON Path to the input JSON document.

+applying the JSONPath to the input JSON value.

Each selector acts on its input list of nodes as follows. For each node in the list, the selector selects zero or more nodes, each of which is a descendant @@ -1478,9 +1477,9 @@

A specific, non-normative example will make this clearer. Suppose the input document is: {"a":[{"b":0},{"b":1},{"c":2}]}. -As we will see later, the JSON Path $.a[*].b selects the following list of nodes: 0, 1. +As we will see later, the JSONPath $.a[*].b selects the following list of nodes: 0, 1. Let's walk through this in detail.

-

The JSON Path consists of $ followed by three selectors: .a, [*], and .b.

+

The JSONPath consists of $ followed by three selectors: .a, [*], and .b.

Firstly, $ selects the root node which is the input document. So the result is a list consisting of just the root node.

@@ -1495,7 +1494,7 @@

The result is a list containing 0, 1. This is the concatenation of three lists, two of length one containing 0, 1, respectively, and one of length zero.

As a consequence of this approach, if any of the selectors selects no nodes, -then the whole JSON Path selects no nodes.

+then the whole JSONPath selects no nodes.

In what follows, the semantics of each selector are defined for each type of node.

@@ -1598,20 +1597,20 @@
-
-2.6.2.3. Union Child +
+2.6.2.3. Child
Syntax
-

A union child is a union element consisting of a quoted string.

+

A child is a quoted string.

-union-element = union-child ; see below for more alternatives
-union-child = %x22 *double-quoted %x22 / ; "string"
-              %x27 *single-quoted %x27   ; 'string'
+union-element = child ; see below for more alternatives
+child = %x22 *double-quoted %x22 / ; "string"
+        %x27 *single-quoted %x27   ; 'string'
 
 double-quoted = dq-unescaped /
           escape (
@@ -1645,10 +1644,13 @@ 
escape = %x5C ; \ HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" + ; case insensitive hex digit
-

Note: double-quoted strings follow JSON in [RFC8259]. -Single-quoted strings follow an analogous pattern.

+

Notes: +1. double-quoted strings follow JSON in [RFC8259]. + Single-quoted strings follow an analogous pattern. +2. HEXDIG includes A-F and a-f.

@@ -1656,7 +1658,7 @@
Semantics
-

If the union child is a quoted string, the string MUST be converted to a +

If the child is a quoted string, the string MUST be converted to a key by removing the surrounding quotes and replacing each escape sequence with its equivalent Unicode character, as in the table below:

@@ -1714,7 +1716,7 @@
-

The union child selects the value corresponding to the key from any object +

The child selects the value corresponding to the key from any object node with the key as a name. It selects no nodes from a node which is not an object.

@@ -1731,8 +1733,7 @@
Syntax
-

An array selector is a union element which selects zero or more elements -of an array node. +

An array selector selects zero or more elements of an array node. An array selector takes the form of an index, which selects at most one element, or a slice, which selects zero or more elements.

@@ -1740,26 +1741,29 @@
union-element =/ array-index / array-slice
-

An array index is a union element consisting of an integer (in base 10).

+

An array index is an integer (in base 10).

 array-index = integer
 
-integer = [%x2D] (%x30 / (%x31-39 *%x30-39))
+integer = ["-"] ("0" / (DIGIT1 *DIGIT))
                             ; optional - followed by 0 or
                             ; sequence of digits with no leading zero
+DIGIT1 = %x31-39            ; non-zero digit
 

Note: the syntax does not allow integers with leading zeros such as 01 and -01.

-

An array slice is a union element consisting of two or three integers (in -base 10 and which may be omitted) separated by colons.

+

An array slice consists of three optional integers (in base 10) separated by colons.

-array-slice = [ integer ] ws %x3A ws [ integer ]
-                   [ ws %x3A ws [ integer ] ]
-                            ; start:end or start:end:step
+array-slice = [ start ] ws ":" ws [ end ]
+                   [ ws ":" ws [ step ] ]
+start = integer
+end = integer
+step = integer
 
+

Note: the array slices : and :: are both syntactically valid, as are :2:2, 2::2, and 2:4:.

diff --git a/draft-normington-jsonpath-latest.html b/draft-normington-jsonpath-latest.html index 7a6c058c..743f636f 100644 --- a/draft-normington-jsonpath-latest.html +++ b/draft-normington-jsonpath-latest.html @@ -9,7 +9,7 @@ @@ -1157,7 +1157,7 @@ Normington, et al. -Expires 21 May 2021 +Expires 30 May 2021 [Page] @@ -1170,12 +1170,12 @@
draft-normington-jsonpath-latest
Published:
- +
Intended Status:
Standards Track
Expires:
-
+
Authors:
@@ -1198,7 +1198,7 @@

JavaScript Object Notation (JSON) Path

Abstract

-

JSON Path defines a string syntax for identifying values +

JSONPath defines a string syntax for identifying values within a JavaScript Object Notation (JSON) document.

@@ -1224,7 +1224,7 @@

time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

- This Internet-Draft will expire on 21 May 2021.

+ This Internet-Draft will expire on 30 May 2021.

-
+
-

-2. JSON Path Syntax and Semantics +

+2. JSONPath Syntax and Semantics

2.1. Overview

-

A JSON Path is a string which selects zero or more nodes of any JSON document. -A valid JSON Path conforms to the ABNF syntax defined by this document.

-

A JSON Path MUST be encoded using UTF-8. To parse a JSON Path according to +

A JSONPath is a string which selects zero or more nodes of a piece of JSON. +A valid JSONPath conforms to the ABNF syntax defined by this document.

+

A JSONPath MUST be encoded using UTF-8. To parse a JSONPath according to the grammar in this document, its UTF-8 form SHOULD first be decoded into Unicode code points as described in [RFC3629].

@@ -1397,8 +1397,7 @@

2.2. Terminology

-

A JSON document is logically a tree of nodes with the document as the root -node of the tree.

+

A JSON value is logically a tree of nodes.

Each node holds a JSON value (as defined by [RFC8259]) of one of the types object, array, number, string, or one of the literals true, false, or null. @@ -1412,23 +1411,23 @@

2.3. Implementation

An implementation of this specification, from now on referred to simply as -"an implementation", SHOULD takes two inputs, a JSON Path and a JSON document, +"an implementation", SHOULD takes two inputs, a JSONPath and a JSON value, and produce -a possibly empty list of nodes of the JSON document which are selected by -the JSON Path or an error (but not both).

+a possibly empty list of nodes of the JSON value which are selected by +the JSONPath or an error (but not both).

If no node is selected and no error has occurred, an implementation MUST return an empty list of nodes.

-

Syntax errors in the JSON Path SHOULD be detected before selection is attempted -since these errors do not depend on the JSON document. -Therefore, an implementation SHOULD take a JSON Path and produce an optional +

Syntax errors in the JSONPath SHOULD be detected before selection is attempted +since these errors do not depend on the JSON value. +Therefore, an implementation SHOULD take a JSONPath and produce an optional syntax error and then, -if and only if an error was not produced, SHOULD take a JSON document and +if and only if an error was not produced, SHOULD take a JSON value and produce a list of nodes or an error (but not both).

-

Alternatively, an implementation MAY take a JSON Path and a JSON document +

Alternatively, an implementation MAY take a JSONPath and a JSON value and produce a list of nodes or an optional error (but not both).

-

For any implementation, if a syntactically invalid JSON Path is provided, +

For any implementation, if a syntactically invalid JSONPath is provided, the implementation MUST return an error.

-

If a syntactially invalid JSON document is provided, any implementation SHOULD +

If a syntactially invalid JSON value is provided, any implementation SHOULD return an error.

@@ -1437,8 +1436,8 @@

2.4. Syntax

-

Syntactically, a JSON Path consists of a root selector ($), which -selects the root node of a JSON document, followed by a possibly empty +

Syntactically, a JSONPath consists of a root selector ($), which +selects the root node of a JSON value, followed by a possibly empty sequence of selectors.

@@ -1465,10 +1464,10 @@ 

simply result in fewer nodes being selected.

But a selector doesn't just act on a single node: each selector acts on a list of nodes and produces a list of nodes, as follows.

-

After the root selector, the remainder of the JSON Path is processed by passing +

After the root selector, the remainder of the JSONPath is processed by passing lists of nodes from one selector to the next ending up with a list of nodes which is the result of -applying the JSON Path to the input JSON document.

+applying the JSONPath to the input JSON value.

Each selector acts on its input list of nodes as follows. For each node in the list, the selector selects zero or more nodes, each of which is a descendant @@ -1478,9 +1477,9 @@

A specific, non-normative example will make this clearer. Suppose the input document is: {"a":[{"b":0},{"b":1},{"c":2}]}. -As we will see later, the JSON Path $.a[*].b selects the following list of nodes: 0, 1. +As we will see later, the JSONPath $.a[*].b selects the following list of nodes: 0, 1. Let's walk through this in detail.

-

The JSON Path consists of $ followed by three selectors: .a, [*], and .b.

+

The JSONPath consists of $ followed by three selectors: .a, [*], and .b.

Firstly, $ selects the root node which is the input document. So the result is a list consisting of just the root node.

@@ -1495,7 +1494,7 @@

The result is a list containing 0, 1. This is the concatenation of three lists, two of length one containing 0, 1, respectively, and one of length zero.

As a consequence of this approach, if any of the selectors selects no nodes, -then the whole JSON Path selects no nodes.

+then the whole JSONPath selects no nodes.

In what follows, the semantics of each selector are defined for each type of node.

@@ -1598,20 +1597,20 @@
-
-2.6.2.3. Union Child +
+2.6.2.3. Child
Syntax
-

A union child is a union element consisting of a quoted string.

+

A child is a quoted string.

-union-element = union-child ; see below for more alternatives
-union-child = %x22 *double-quoted %x22 / ; "string"
-              %x27 *single-quoted %x27   ; 'string'
+union-element = child ; see below for more alternatives
+child = %x22 *double-quoted %x22 / ; "string"
+        %x27 *single-quoted %x27   ; 'string'
 
 double-quoted = dq-unescaped /
           escape (
@@ -1645,10 +1644,13 @@ 
escape = %x5C ; \ HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" + ; case insensitive hex digit
-

Note: double-quoted strings follow JSON in [RFC8259]. -Single-quoted strings follow an analogous pattern.

+

Notes: +1. double-quoted strings follow JSON in [RFC8259]. + Single-quoted strings follow an analogous pattern. +2. HEXDIG includes A-F and a-f.

@@ -1656,7 +1658,7 @@
Semantics
-

If the union child is a quoted string, the string MUST be converted to a +

If the child is a quoted string, the string MUST be converted to a key by removing the surrounding quotes and replacing each escape sequence with its equivalent Unicode character, as in the table below:

@@ -1714,7 +1716,7 @@
-

The union child selects the value corresponding to the key from any object +

The child selects the value corresponding to the key from any object node with the key as a name. It selects no nodes from a node which is not an object.

@@ -1731,8 +1733,7 @@
Syntax
-

An array selector is a union element which selects zero or more elements -of an array node. +

An array selector selects zero or more elements of an array node. An array selector takes the form of an index, which selects at most one element, or a slice, which selects zero or more elements.

@@ -1740,26 +1741,29 @@
union-element =/ array-index / array-slice
-

An array index is a union element consisting of an integer (in base 10).

+

An array index is an integer (in base 10).

 array-index = integer
 
-integer = [%x2D] (%x30 / (%x31-39 *%x30-39))
+integer = ["-"] ("0" / (DIGIT1 *DIGIT))
                             ; optional - followed by 0 or
                             ; sequence of digits with no leading zero
+DIGIT1 = %x31-39            ; non-zero digit
 

Note: the syntax does not allow integers with leading zeros such as 01 and -01.

-

An array slice is a union element consisting of two or three integers (in -base 10 and which may be omitted) separated by colons.

+

An array slice consists of three optional integers (in base 10) separated by colons.

-array-slice = [ integer ] ws %x3A ws [ integer ]
-                   [ ws %x3A ws [ integer ] ]
-                            ; start:end or start:end:step
+array-slice = [ start ] ws ":" ws [ end ]
+                   [ ws ":" ws [ step ] ]
+start = integer
+end = integer
+step = integer
 
+

Note: the array slices : and :: are both syntactically valid, as are :2:2, 2::2, and 2:4:.

diff --git a/draft-normington-jsonpath-latest.md b/draft-normington-jsonpath-latest.md index c7405f9c..a6f56abf 100644 --- a/draft-normington-jsonpath-latest.md +++ b/draft-normington-jsonpath-latest.md @@ -89,7 +89,7 @@ normative: --- abstract -JSON Path defines a string syntax for identifying values +JSONPath defines a string syntax for identifying values within a JavaScript Object Notation (JSON) document. --- note_ @@ -101,7 +101,7 @@ as an Internet Draft.** # Introduction -JSON Path, or rather JSONPath, was introduced by Stefan Goessner as a simple +JSONPath was introduced by Stefan Goessner as a simple form of XPath for JSON. See his original article {{Goessner}}. @@ -122,14 +122,14 @@ in ABNF as `%x2318`. -# JSON Path Syntax and Semantics +# JSONPath Syntax and Semantics ## Overview -A JSON Path is a string which selects zero or more nodes of any JSON document. -A valid JSON Path conforms to the ABNF syntax defined by this document. +A JSONPath is a string which selects zero or more nodes of a piece of JSON. +A valid JSONPath conforms to the ABNF syntax defined by this document. -A JSON Path MUST be encoded using UTF-8. To parse a JSON Path according to +A JSONPath MUST be encoded using UTF-8. To parse a JSONPath according to the grammar in this document, its UTF-8 form SHOULD first be decoded into Unicode code points as described in {{RFC3629}}. @@ -137,8 +137,7 @@ in {{RFC3629}}. ## Terminology -A JSON document is logically a tree of nodes with the document as the root -node of the tree. +A JSON value is logically a tree of nodes. Each node holds a JSON value (as defined by {{RFC8259}}) of one of the types object, array, number, string, or one of the literals `true`, @@ -150,35 +149,35 @@ sometimes referred to as the type of the node. ## Implementation An implementation of this specification, from now on referred to simply as -"an implementation", SHOULD takes two inputs, a JSON Path and a JSON document, +"an implementation", SHOULD takes two inputs, a JSONPath and a JSON value, and produce -a possibly empty list of nodes of the JSON document which are selected by -the JSON Path or an error (but not both). +a possibly empty list of nodes of the JSON value which are selected by +the JSONPath or an error (but not both). If no node is selected and no error has occurred, an implementation MUST return an empty list of nodes. -Syntax errors in the JSON Path SHOULD be detected before selection is attempted -since these errors do not depend on the JSON document. -Therefore, an implementation SHOULD take a JSON Path and produce an optional +Syntax errors in the JSONPath SHOULD be detected before selection is attempted +since these errors do not depend on the JSON value. +Therefore, an implementation SHOULD take a JSONPath and produce an optional syntax error and then, -if and only if an error was not produced, SHOULD take a JSON document and +if and only if an error was not produced, SHOULD take a JSON value and produce a list of nodes or an error (but not both). -Alternatively, an implementation MAY take a JSON Path and a JSON document +Alternatively, an implementation MAY take a JSONPath and a JSON value and produce a list of nodes or an optional error (but not both). -For any implementation, if a syntactically invalid JSON Path is provided, +For any implementation, if a syntactically invalid JSONPath is provided, the implementation MUST return an error. -If a syntactially invalid JSON document is provided, any implementation SHOULD +If a syntactially invalid JSON value is provided, any implementation SHOULD return an error. ## Syntax -Syntactically, a JSON Path consists of a root selector (`$`), which -selects the root node of a JSON document, followed by a possibly empty +Syntactically, a JSONPath consists of a root selector (`$`), which +selects the root node of a JSON value, followed by a possibly empty sequence of *selectors*. ~~~~ abnf @@ -205,10 +204,10 @@ simply result in fewer nodes being selected. But a selector doesn't just act on a single node: each selector acts on a list of nodes and produces a list of nodes, as follows. -After the root selector, the remainder of the JSON Path is processed by passing +After the root selector, the remainder of the JSONPath is processed by passing lists of nodes from one selector to the next ending up with a list of nodes which is the result of -applying the JSON Path to the input JSON document. +applying the JSONPath to the input JSON value. Each selector acts on its input list of nodes as follows. For each node in @@ -220,10 +219,10 @@ of selected nodes for each input node. A specific, non-normative example will make this clearer. Suppose the input document is: `{"a":[{"b":0},{"b":1},{"c":2}]}`. -As we will see later, the JSON Path `$.a[*].b` selects the following list of nodes: `0`, `1`. +As we will see later, the JSONPath `$.a[*].b` selects the following list of nodes: `0`, `1`. Let's walk through this in detail. -The JSON Path consists of `$` followed by three selectors: `.a`, `[*]`, and `.b`. +The JSONPath consists of `$` followed by three selectors: `.a`, `[*]`, and `.b`. Firstly, `$` selects the root node which is the input document. So the result is a list @@ -243,7 +242,7 @@ The result is a list containing `0`, `1`. This is the concatenation of three lists, two of length one containing `0`, `1`, respectively, and one of length zero. As a consequence of this approach, if any of the selectors selects no nodes, -then the whole JSON Path selects no nodes. +then the whole JSONPath selects no nodes. In what follows, the semantics of each selector are defined for each type of node. @@ -328,17 +327,17 @@ and selects the concatenation of the lists (in the order of the selectors) of nodes selected by the union elements. -#### Union Child {#unionchild} +#### Child {#unionchild} ##### Syntax {: numbered="false" toc="exclude"} -A union child is a union element consisting of a quoted string. +A child is a quoted string. ~~~~ abnf -union-element = union-child ; see below for more alternatives -union-child = %x22 *double-quoted %x22 / ; "string" - %x27 *single-quoted %x27 ; 'string' +union-element = child ; see below for more alternatives +child = %x22 *double-quoted %x22 / ; "string" + %x27 *single-quoted %x27 ; 'string' double-quoted = dq-unescaped / escape ( @@ -372,16 +371,19 @@ single-quoted = sq-unescaped / escape = %x5C ; \ HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" + ; case insensitive hex digit ~~~~ -Note: double-quoted strings follow JSON in {{RFC8259}}. -Single-quoted strings follow an analogous pattern. +Notes: +1. double-quoted strings follow JSON in {{RFC8259}}. + Single-quoted strings follow an analogous pattern. +2. `HEXDIG` includes A-F and a-f. ##### Semantics {: numbered="false" toc="exclude"} -If the union child is a quoted string, the string MUST be converted to a +If the child is a quoted string, the string MUST be converted to a key by removing the surrounding quotes and replacing each escape sequence with its equivalent Unicode character, as in the table below: @@ -400,7 +402,7 @@ in the table below: | %x5C uXXXX | U+XXXX | {: title="Escape Sequence Replacements" cols="c c"} -The union child selects the value corresponding to the key from any object +The child selects the value corresponding to the key from any object node with the key as a name. It selects no nodes from a node which is not an object. @@ -411,8 +413,7 @@ It selects no nodes from a node which is not an object. ##### Syntax {: numbered="false" toc="exclude"} -An array selector is a union element which selects zero or more elements -of an array node. +An array selector selects zero or more elements of an array node. An array selector takes the form of an index, which selects at most one element, or a slice, which selects zero or more elements. @@ -420,27 +421,30 @@ or a slice, which selects zero or more elements. union-element =/ array-index / array-slice ~~~~ -An array index is a union element consisting of an integer (in base 10). +An array index is an integer (in base 10). ~~~~ abnf array-index = integer -integer = [%x2D] (%x30 / (%x31-39 *%x30-39)) +integer = ["-"] ("0" / (DIGIT1 *DIGIT)) ; optional - followed by 0 or ; sequence of digits with no leading zero +DIGIT1 = %x31-39 ; non-zero digit ~~~~ Note: the syntax does not allow integers with leading zeros such as `01` and `-01`. -An array slice is a union element consisting of two or three integers (in -base 10 and which may be omitted) separated by colons. +An array slice consists of three optional integers (in base 10) separated by colons. ~~~~ abnf -array-slice = [ integer ] ws %x3A ws [ integer ] - [ ws %x3A ws [ integer ] ] - ; start:end or start:end:step +array-slice = [ start ] ws ":" ws [ end ] + [ ws ":" ws [ step ] ] +start = integer +end = integer +step = integer ~~~~ +Note: the array slices `:` and `::` are both syntactically valid, as are `:2:2`, `2::2`, and `2:4:`. ##### Semantics {: numbered="false" toc="exclude"} diff --git a/draft-normington-jsonpath-latest.txt b/draft-normington-jsonpath-latest.txt index 7094712e..dd9b49f5 100644 --- a/draft-normington-jsonpath-latest.txt +++ b/draft-normington-jsonpath-latest.txt @@ -5,10 +5,10 @@ Internet Engineering Task Force G. Normington, Ed. Internet-Draft VMware, Inc. Intended status: Standards Track E. Surov, Ed. -Expires: 21 May 2021 TheSoul Publishing Ltd. +Expires: 30 May 2021 TheSoul Publishing Ltd. M. Mikulicic VMware, Inc. - 17 November 2020 + 26 November 2020 JavaScript Object Notation (JSON) Path @@ -16,7 +16,7 @@ Expires: 21 May 2021 TheSoul Publishing Ltd. Abstract - JSON Path defines a string syntax for identifying values within a + JSONPath defines a string syntax for identifying values within a JavaScript Object Notation (JSON) document. Note @@ -39,7 +39,7 @@ Status of This Memo time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." - This Internet-Draft will expire on 21 May 2021. + This Internet-Draft will expire on 30 May 2021. Copyright Notice @@ -53,7 +53,7 @@ Copyright Notice -Normington, et al. Expires 21 May 2021 [Page 1] +Normington, et al. Expires 30 May 2021 [Page 1] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 @@ -68,7 +68,7 @@ Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1.1. Requirements Language . . . . . . . . . . . . . . . . . . 2 1.2. ABNF Syntax . . . . . . . . . . . . . . . . . . . . . . . 3 - 2. JSON Path Syntax and Semantics . . . . . . . . . . . . . . . 3 + 2. JSONPath Syntax and Semantics . . . . . . . . . . . . . . . . 3 2.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2. Terminology . . . . . . . . . . . . . . . . . . . . . . . 3 2.3. Implementation . . . . . . . . . . . . . . . . . . . . . 3 @@ -79,7 +79,7 @@ Table of Contents 2.6.2. Union Selector . . . . . . . . . . . . . . . . . . . 6 2.6.2.1. Syntax . . . . . . . . . . . . . . . . . . . . . 6 2.6.2.2. Semantics . . . . . . . . . . . . . . . . . . . . 7 - 2.6.2.3. Union Child . . . . . . . . . . . . . . . . . . . 7 + 2.6.2.3. Child . . . . . . . . . . . . . . . . . . . . . . 7 2.6.2.4. Array Selector . . . . . . . . . . . . . . . . . 9 3. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 13 4. Security Considerations . . . . . . . . . . . . . . . . . . . 13 @@ -92,8 +92,8 @@ Table of Contents 1. Introduction - JSON Path, or rather JSONPath, was introduced by Stefan Goessner as a - simple form of XPath for JSON. See his original article [Goessner]. + JSONPath was introduced by Stefan Goessner as a simple form of XPath + for JSON. See his original article [Goessner]. JSON is defined by [RFC8259]. @@ -109,7 +109,7 @@ Table of Contents -Normington, et al. Expires 21 May 2021 [Page 2] +Normington, et al. Expires 30 May 2021 [Page 2] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 @@ -122,22 +122,21 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 rather than their UTF-8 encoding. For example, the Unicode PLACE OF INTEREST SIGN (U+2318) would be defined in ABNF as "%x2318". -2. JSON Path Syntax and Semantics +2. JSONPath Syntax and Semantics 2.1. Overview - A JSON Path is a string which selects zero or more nodes of any JSON - document. A valid JSON Path conforms to the ABNF syntax defined by - this document. + A JSONPath is a string which selects zero or more nodes of a piece of + JSON. A valid JSONPath conforms to the ABNF syntax defined by this + document. - A JSON Path MUST be encoded using UTF-8. To parse a JSON Path + A JSONPath MUST be encoded using UTF-8. To parse a JSONPath according to the grammar in this document, its UTF-8 form SHOULD first be decoded into Unicode code points as described in [RFC3629]. 2.2. Terminology - A JSON document is logically a tree of nodes with the document as the - root node of the tree. + A JSON value is logically a tree of nodes. Each node holds a JSON value (as defined by [RFC8259]) of one of the types object, array, number, string, or one of the literals "true", @@ -147,44 +146,44 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 2.3. Implementation An implementation of this specification, from now on referred to - simply as "an implementation", SHOULD takes two inputs, a JSON Path - and a JSON document, and produce a possibly empty list of nodes of - the JSON document which are selected by the JSON Path or an error - (but not both). + simply as "an implementation", SHOULD takes two inputs, a JSONPath + and a JSON value, and produce a possibly empty list of nodes of the + JSON value which are selected by the JSONPath or an error (but not + both). If no node is selected and no error has occurred, an implementation MUST return an empty list of nodes. - Syntax errors in the JSON Path SHOULD be detected before selection is - attempted since these errors do not depend on the JSON document. - Therefore, an implementation SHOULD take a JSON Path and produce an + Syntax errors in the JSONPath SHOULD be detected before selection is + attempted since these errors do not depend on the JSON value. + Therefore, an implementation SHOULD take a JSONPath and produce an optional syntax error and then, if and only if an error was not - produced, SHOULD take a JSON document and produce a list of nodes or - an error (but not both). + produced, SHOULD take a JSON value and produce a list of nodes or an + error (but not both). + -Normington, et al. Expires 21 May 2021 [Page 3] +Normington, et al. Expires 30 May 2021 [Page 3] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 - Alternatively, an implementation MAY take a JSON Path and a JSON - document and produce a list of nodes or an optional error (but not - both). + Alternatively, an implementation MAY take a JSONPath and a JSON value + and produce a list of nodes or an optional error (but not both). - For any implementation, if a syntactically invalid JSON Path is + For any implementation, if a syntactically invalid JSONPath is provided, the implementation MUST return an error. - If a syntactially invalid JSON document is provided, any - implementation SHOULD return an error. + If a syntactially invalid JSON value is provided, any implementation + SHOULD return an error. 2.4. Syntax - Syntactically, a JSON Path consists of a root selector ("$"), which - selects the root node of a JSON document, followed by a possibly - empty sequence of _selectors_. + Syntactically, a JSONPath consists of a root selector ("$"), which + selects the root node of a JSON value, followed by a possibly empty + sequence of _selectors_. json-path = root-selector *selector root-selector = %x24 ; $ selects document root node @@ -206,10 +205,10 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 But a selector doesn't just act on a single node: each selector acts on a list of nodes and produces a list of nodes, as follows. - After the root selector, the remainder of the JSON Path is processed + After the root selector, the remainder of the JSONPath is processed by passing lists of nodes from one selector to the next ending up - with a list of nodes which is the result of applying the JSON Path to - the input JSON document. + with a list of nodes which is the result of applying the JSONPath to + the input JSON value. Each selector acts on its input list of nodes as follows. For each node in the list, the selector selects zero or more nodes, each of @@ -221,17 +220,18 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 -Normington, et al. Expires 21 May 2021 [Page 4] + +Normington, et al. Expires 30 May 2021 [Page 4] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 A specific, non-normative example will make this clearer. Suppose the input document is: "{"a":[{"b":0},{"b":1},{"c":2}]}". As we will - see later, the JSON Path "$.a[*].b" selects the following list of + see later, the JSONPath "$.a[*].b" selects the following list of nodes: "0", "1". Let's walk through this in detail. - The JSON Path consists of "$" followed by three selectors: ".a", + The JSONPath consists of "$" followed by three selectors: ".a", "[*]", and ".b". Firstly, "$" selects the root node which is the input document. So @@ -252,7 +252,7 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 respectively, and one of length zero. As a consequence of this approach, if any of the selectors selects no - nodes, then the whole JSON Path selects no nodes. + nodes, then the whole JSONPath selects no nodes. In what follows, the semantics of each selector are defined for each type of node. @@ -277,7 +277,7 @@ Syntax -Normington, et al. Expires 21 May 2021 [Page 5] +Normington, et al. Expires 30 May 2021 [Page 5] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 @@ -333,7 +333,7 @@ Semantics -Normington, et al. Expires 21 May 2021 [Page 6] +Normington, et al. Expires 30 May 2021 [Page 6] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 @@ -351,11 +351,11 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 union selectors and selects the concatenation of the lists (in the order of the selectors) of nodes selected by the union elements. -2.6.2.3. Union Child +2.6.2.3. Child Syntax - A union child is a union element consisting of a quoted string. + A child is a quoted string. @@ -389,14 +389,14 @@ Syntax -Normington, et al. Expires 21 May 2021 [Page 7] +Normington, et al. Expires 30 May 2021 [Page 7] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 - union-element = union-child ; see below for more alternatives - union-child = %x22 *double-quoted %x22 / ; "string" - %x27 *single-quoted %x27 ; 'string' + union-element = child ; see below for more alternatives + child = %x22 *double-quoted %x22 / ; "string" + %x27 *single-quoted %x27 ; 'string' double-quoted = dq-unescaped / escape ( @@ -430,22 +430,22 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 escape = %x5C ; \ HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" + ; case insensitive hex digit - Note: double-quoted strings follow JSON in [RFC8259]. Single-quoted - strings follow an analogous pattern. + Notes: 1. double-quoted strings follow JSON in [RFC8259]. Single- + quoted strings follow an analogous pattern. 2. "HEXDIG" includes A-F + and a-f. Semantics - If the union child is a quoted string, the string MUST be converted - to a key by removing the surrounding quotes and replacing each escape + If the child is a quoted string, the string MUST be converted to a + key by removing the surrounding quotes and replacing each escape sequence with its equivalent Unicode character, as in the table below: - - -Normington, et al. Expires 21 May 2021 [Page 8] +Normington, et al. Expires 30 May 2021 [Page 8] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 @@ -476,51 +476,50 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 Table 1: Escape Sequence Replacements - The union child selects the value corresponding to the key from any - object node with the key as a name. It selects no nodes from a node - which is not an object. + The child selects the value corresponding to the key from any object + node with the key as a name. It selects no nodes from a node which + is not an object. 2.6.2.4. Array Selector Syntax - An array selector is a union element which selects zero or more - elements of an array node. An array selector takes the form of an - index, which selects at most one element, or a slice, which selects - zero or more elements. + An array selector selects zero or more elements of an array node. An + array selector takes the form of an index, which selects at most one + element, or a slice, which selects zero or more elements. union-element =/ array-index / array-slice - An array index is a union element consisting of an integer (in base - 10). - - - + An array index is an integer (in base 10). + array-index = integer + integer = ["-"] ("0" / (DIGIT1 *DIGIT)) + ; optional - followed by 0 or + ; sequence of digits with no leading zero + DIGIT1 = %x31-39 ; non-zero digit -Normington, et al. Expires 21 May 2021 [Page 9] +Normington, et al. Expires 30 May 2021 [Page 9] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 - array-index = integer - - integer = [%x2D] (%x30 / (%x31-39 *%x30-39)) - ; optional - followed by 0 or - ; sequence of digits with no leading zero - Note: the syntax does not allow integers with leading zeros such as "01" and "-01". - An array slice is a union element consisting of two or three integers - (in base 10 and which may be omitted) separated by colons. + An array slice consists of three optional integers (in base 10) + separated by colons. - array-slice = [ integer ] ws %x3A ws [ integer ] - [ ws %x3A ws [ integer ] ] - ; start:end or start:end:step + array-slice = [ start ] ws ":" ws [ end ] + [ ws ":" ws [ step ] ] + start = integer + end = integer + step = integer + + Note: the array slices ":" and "::" are both syntactically valid, as + are ":2:2", "2::2", and "2:4:". Semantics @@ -557,7 +556,8 @@ Informal Introduction -Normington, et al. Expires 21 May 2021 [Page 10] + +Normington, et al. Expires 30 May 2021 [Page 10] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 @@ -613,7 +613,7 @@ Detailed Semantics -Normington, et al. Expires 21 May 2021 [Page 11] +Normington, et al. Expires 30 May 2021 [Page 11] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 @@ -669,7 +669,7 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 -Normington, et al. Expires 21 May 2021 [Page 12] +Normington, et al. Expires 30 May 2021 [Page 12] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 @@ -725,7 +725,7 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 -Normington, et al. Expires 21 May 2021 [Page 13] +Normington, et al. Expires 30 May 2021 [Page 13] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 @@ -781,7 +781,7 @@ Authors' Addresses -Normington, et al. Expires 21 May 2021 [Page 14] +Normington, et al. Expires 30 May 2021 [Page 14] Internet-Draft JavaScript Object Notation (JSON) Path November 2020 @@ -837,4 +837,4 @@ Internet-Draft JavaScript Object Notation (JSON) Path November 2020 -Normington, et al. Expires 21 May 2021 [Page 15] +Normington, et al. Expires 30 May 2021 [Page 15] diff --git a/draft-normington-jsonpath-latest.xml b/draft-normington-jsonpath-latest.xml index 2d1140bb..dfe6da7d 100644 --- a/draft-normington-jsonpath-latest.xml +++ b/draft-normington-jsonpath-latest.xml @@ -67,7 +67,7 @@ -JSON Path defines a string syntax for identifying values +JSONPath defines a string syntax for identifying values within a JavaScript Object Notation (JSON) document. @@ -92,7 +92,7 @@ as an Internet Draft.
-JSON Path, or rather JSONPath, was introduced by Stefan Goessner as a simple +JSONPath was introduced by Stefan Goessner as a simple form of XPath for JSON. See his original article . @@ -118,14 +118,14 @@ in ABNF as %x2318.
-
+
-A JSON Path is a string which selects zero or more nodes of any JSON document. -A valid JSON Path conforms to the ABNF syntax defined by this document. +A JSONPath is a string which selects zero or more nodes of a piece of JSON. +A valid JSONPath conforms to the ABNF syntax defined by this document. -A JSON Path MUST be encoded using UTF-8. To parse a JSON Path according to +A JSONPath MUST be encoded using UTF-8. To parse a JSONPath according to the grammar in this document, its UTF-8 form SHOULD first be decoded into Unicode code points as described in . @@ -133,8 +133,7 @@ in .
-A JSON document is logically a tree of nodes with the document as the root -node of the tree. +A JSON value is logically a tree of nodes. Each node holds a JSON value (as defined by ) of one of the types object, array, number, string, or one of the literals true, @@ -146,35 +145,35 @@ sometimes referred to as the type of the node.
An implementation of this specification, from now on referred to simply as -"an implementation", SHOULD takes two inputs, a JSON Path and a JSON document, +"an implementation", SHOULD takes two inputs, a JSONPath and a JSON value, and produce -a possibly empty list of nodes of the JSON document which are selected by -the JSON Path or an error (but not both). +a possibly empty list of nodes of the JSON value which are selected by +the JSONPath or an error (but not both). If no node is selected and no error has occurred, an implementation MUST return an empty list of nodes. -Syntax errors in the JSON Path SHOULD be detected before selection is attempted -since these errors do not depend on the JSON document. -Therefore, an implementation SHOULD take a JSON Path and produce an optional +Syntax errors in the JSONPath SHOULD be detected before selection is attempted +since these errors do not depend on the JSON value. +Therefore, an implementation SHOULD take a JSONPath and produce an optional syntax error and then, -if and only if an error was not produced, SHOULD take a JSON document and +if and only if an error was not produced, SHOULD take a JSON value and produce a list of nodes or an error (but not both). -Alternatively, an implementation MAY take a JSON Path and a JSON document +Alternatively, an implementation MAY take a JSONPath and a JSON value and produce a list of nodes or an optional error (but not both). -For any implementation, if a syntactically invalid JSON Path is provided, +For any implementation, if a syntactically invalid JSONPath is provided, the implementation MUST return an error. -If a syntactially invalid JSON document is provided, any implementation SHOULD +If a syntactially invalid JSON value is provided, any implementation SHOULD return an error.
-Syntactically, a JSON Path consists of a root selector ($), which -selects the root node of a JSON document, followed by a possibly empty +Syntactically, a JSONPath consists of a root selector ($), which +selects the root node of a JSON value, followed by a possibly empty sequence of selectors.
But a selector doesn't just act on a single node: each selector acts on a list of nodes and produces a list of nodes, as follows. -After the root selector, the remainder of the JSON Path is processed by passing +After the root selector, the remainder of the JSONPath is processed by passing lists of nodes from one selector to the next ending up with a list of nodes which is the result of -applying the JSON Path to the input JSON document. +applying the JSONPath to the input JSON value. Each selector acts on its input list of nodes as follows. For each node in @@ -216,10 +215,10 @@ of selected nodes for each input node. A specific, non-normative example will make this clearer. Suppose the input document is: {"a":[{"b":0},{"b":1},{"c":2}]}. -As we will see later, the JSON Path $.a[*].b selects the following list of nodes: 0, 1. +As we will see later, the JSONPath $.a[*].b selects the following list of nodes: 0, 1. Let's walk through this in detail. -The JSON Path consists of $ followed by three selectors: .a, [*], and .b. +The JSONPath consists of $ followed by three selectors: .a, [*], and .b. Firstly, $ selects the root node which is the input document. So the result is a list @@ -239,7 +238,7 @@ The result is a list containing 0, 0, 1, respectively, and one of length zero. As a consequence of this approach, if any of the selectors selects no nodes, -then the whole JSON Path selects no nodes. +then the whole JSONPath selects no nodes. In what follows, the semantics of each selector are defined for each type of node. @@ -322,16 +321,16 @@ and selects the concatenation of the lists (in the order of the selectors) of nodes selected by the union elements.
-
+
-A union child is a union element consisting of a quoted string. +A child is a quoted string.
-Note: double-quoted strings follow JSON in . -Single-quoted strings follow an analogous pattern. +Notes: +1. double-quoted strings follow JSON in . + Single-quoted strings follow an analogous pattern. +2. HEXDIG includes A-F and a-f.
-If the union child is a quoted string, the string MUST be converted to a +If the child is a quoted string, the string MUST be converted to a key by removing the surrounding quotes and replacing each escape sequence with its equivalent Unicode character, as in the table below: @@ -403,7 +405,7 @@ in the table below: U+XXXX -The union child selects the value corresponding to the key from any object +The child selects the value corresponding to the key from any object node with the key as a name. It selects no nodes from a node which is not an object. @@ -413,8 +415,7 @@ It selects no nodes from a node which is not an object.
-An array selector is a union element which selects zero or more elements -of an array node. +An array selector selects zero or more elements of an array node. An array selector takes the form of an index, which selects at most one element, or a slice, which selects zero or more elements. @@ -422,27 +423,31 @@ or a slice, which selects zero or more elements. union-element =/ array-index / array-slice ]]> -An array index is a union element consisting of an integer (in base 10). +An array index is an integer (in base 10).
Note: the syntax does not allow integers with leading zeros such as 01 and -01. -An array slice is a union element consisting of two or three integers (in -base 10 and which may be omitted) separated by colons. +An array slice consists of three optional integers (in base 10) separated by colons.
+Note: the array slices : and :: are both syntactically valid, as are :2:2, 2::2, and 2:4:. +
@@ -789,148 +794,149 @@ be removed during conversion into an RFC by the RFC Editor.