Skip to content

Commit 103fcd5

Browse files
committed
docs ✏️ shorten
1 parent c497205 commit 103fcd5

File tree

1 file changed

+22
-257
lines changed

1 file changed

+22
-257
lines changed

src/json-path/__context__/rfc9535-short.txt

Lines changed: 22 additions & 257 deletions
Original file line numberDiff line numberDiff line change
@@ -433,30 +433,7 @@ Example: $ applied to {"k": "v"} returns [{"k": "v"}]
433433

434434
2.3.4.2.1. Informal Introduction
435435

436-
This section is informative.
437-
438-
Array slicing is inspired by the behavior of the
439-
Array.prototype.slice method of the JavaScript language, as defined
440-
by the ECMA-262 standard [ECMA-262], with the addition of the step
441-
parameter, which is inspired by the Python slice expression.
442-
443-
The array slice expression start:end:step selects elements at indices
444-
starting at start, incrementing by step, and ending with end (which
445-
is itself excluded). So, for example, the expression 1:3 (where step
446-
defaults to 1) selects elements with indices 1 and 2 (in that order),
447-
whereas 1:5:2 selects elements with indices 1 and 3.
448-
449-
When step is negative, elements are selected in reverse order. Thus,
450-
for example, 5:1:-2 selects elements with indices 5 and 3 (in that
451-
order), and ::-1 selects all the elements of an array in reverse
452-
order.
453-
454-
When step is 0, no elements are selected. (This is the one case that
455-
differs from the behavior of Python, which raises an error in this
456-
case.)
457-
458-
The following section specifies the behavior fully, without depending
459-
on JavaScript or Python behavior.
436+
Array slicing: start:end:step selects indices from start (inclusive) to end (exclusive) by step. Negative step reverses order. Step 0 selects nothing.
460437

461438
2.3.4.2.2. Normative Semantics
462439

@@ -590,146 +567,46 @@ Example: $ applied to {"k": "v"} returns [{"k": "v"}]
590567

591568
2.3.5. Filter Selector
592569

593-
Filter selectors are used to iterate over the elements or members of
594-
structured values, i.e., JSON arrays and objects. The structured
595-
values are identified in the nodelist offered by the child or
596-
descendant segment using the filter selector.
597-
598-
For each iteration (element/member), a logical expression (the
599-
_filter expression_) is evaluated, which decides whether the node of
600-
the element/member is selected. (While a logical expression
601-
evaluates to what mathematically is a Boolean value, this
602-
specification uses the term _logical_ to maintain a distinction from
603-
the Boolean values that JSON can represent.)
604-
605-
During the iteration process, the filter expression receives the node
606-
of each array element or object member value of the structured value
607-
being filtered; this element or member value is then known as the
608-
_current node_.
609-
610-
The current node can be used as the start of one or more JSONPath
611-
queries in subexpressions of the filter expression, notated via the
612-
current-node-identifier @. Each JSONPath query can be used either for
613-
testing existence of a result of the query, for obtaining a specific
614-
JSON value resulting from that query that can then be used in a
615-
comparison, or as a _function argument_.
616-
617-
Filter selectors may use function extensions, which are covered in
618-
Section 2.4. Within the logical expression for a filter selector,
619-
function expressions can be used to operate on nodelists and values.
620-
The set of available functions is extensible, with a number of
621-
functions predefined (see Section 2.4) and the ability to register
622-
further functions provided by the "Function Extensions" subregistry
623-
(Section 3.2). When a function is defined, it is given a unique
624-
name, and its return value and each of its parameters are given a
625-
_declared type_. The type system is limited in scope; its purpose is
626-
to express restrictions that, without functions, are implicit in the
627-
grammar of filter expressions. The type system also guides
628-
conversions (Section 2.4.2) that mimic the way different kinds of
629-
expressions are handled in the grammar when function expressions are
630-
not in use.
570+
Filter selectors iterate over array elements or object members, evaluating a logical expression for each to decide selection. The current node (@) represents each element/member being tested. Supports function extensions with declared types for parameters and results.
631571

632572
2.3.5.1. Syntax
633573

634-
The filter selector has the form ?<logical-expr>.
574+
Filter selector: ?<logical-expr>. Supports Boolean operators (||, &&, !), comparisons (==, !=, <, <=, >, >=), existence tests, and function expressions. Current node accessible via @.
635575

636576
filter-selector = "?" S logical-expr
637577

638-
As the filter expression is composed of constituents free of side
639-
effects, the order of evaluation does not need to be (and is not)
640-
defined. Similarly, for conjunction (&&) and disjunction (||)
641-
(defined later), both a short-circuiting and a fully evaluating
642-
implementation will lead to the same result; both implementation
643-
strategies are therefore valid.
644-
645-
The current node is accessible via the current node identifier @.
646-
This identifier addresses the current node of the filter-selector
647-
that is directly enclosing the identifier. Note: Within nested
648-
filter-selectors, there is no syntax to address the current node of
649-
any other than the directly enclosing filter-selector (i.e., of
650-
filter-selectors enclosing the filter-selector that is directly
651-
enclosing the identifier).
652-
653-
Logical expressions offer the usual Boolean operators (|| for OR, &&
654-
for AND, and ! for NOT). They have the normal semantics of Boolean
655-
algebra and obey its laws (for example, see [BOOLEAN-LAWS]).
656-
Parentheses MAY be used within logical-expr for grouping.
657-
658-
It is not required that logical-expr consist of a parenthesized
659-
expression (which was required in [JSONPath-orig]), although it can
660-
be, and the semantics are the same as without the parentheses.
661-
662578
logical-expr = logical-or-expr
663579
logical-or-expr = logical-and-expr *(S "||" S logical-and-expr)
664-
; disjunction
665-
; binds less tightly than conjunction
666580
logical-and-expr = basic-expr *(S "&&" S basic-expr)
667-
; conjunction
668-
; binds more tightly than disjunction
669-
670-
basic-expr = paren-expr /
671-
comparison-expr /
672-
test-expr
673581

582+
basic-expr = paren-expr / comparison-expr / test-expr
674583
paren-expr = [logical-not-op S] "(" S logical-expr S ")"
675-
; parenthesized expression
676-
logical-not-op = "!" ; logical NOT operator
677-
678-
A test expression either tests the existence of a node designated by
679-
an embedded query (see Section 2.3.5.2.1) or tests the result of a
680-
function expression (see Section 2.4). In the latter case, if the
681-
function's declared result type is LogicalType (see Section 2.4.1),
682-
it tests whether the result is LogicalTrue; if the function's
683-
declared result type is NodesType, it tests whether the result is
684-
non-empty. If the function's declared result type is ValueType, its
685-
use in a test expression is not well-typed (see Section 2.4.3).
584+
logical-not-op = "!"
686585

687586
test-expr = [logical-not-op S]
688-
(filter-query / ; existence/non-existence
689-
function-expr) ; LogicalType or NodesType
587+
(filter-query / function-expr)
690588
filter-query = rel-query / jsonpath-query
691589
rel-query = current-node-identifier segments
692590
current-node-identifier = "@"
693591

694-
Comparison expressions are available for comparisons between
695-
primitive values (that is, numbers, strings, true, false, and null).
696-
These can be obtained via literal values; singular queries, each of
697-
which selects at most one node, the value of which is then used; or
698-
function expressions (see Section 2.4) of type ValueType.
699-
700592
comparison-expr = comparable S comparison-op S comparable
701-
literal = number / string-literal /
702-
true / false / null
703-
comparable = literal /
704-
singular-query / ; singular query value
705-
function-expr ; ValueType
706-
comparison-op = "==" / "!=" /
707-
"<=" / ">=" /
708-
"<" / ">"
593+
literal = number / string-literal / true / false / null
594+
comparable = literal / singular-query / function-expr
595+
comparison-op = "==" / "!=" / "<=" / ">=" / "<" / ">"
709596

710597
singular-query = rel-singular-query / abs-singular-query
711598
rel-singular-query = current-node-identifier singular-query-segments
712599
abs-singular-query = root-identifier singular-query-segments
713600
singular-query-segments = *(S (name-segment / index-segment))
714-
name-segment = ("[" name-selector "]") /
715-
("." member-name-shorthand)
601+
name-segment = ("[" name-selector "]") / ("." member-name-shorthand)
716602
index-segment = "[" index-selector "]"
717603

718-
Literals can be notated in the way that is usual for JSON (with the
719-
extension that strings can use single-quote delimiters).
720-
721-
Note: Alphabetic characters in quoted strings are case-insensitive in
722-
ABNF, so within a floating point number, the ABNF expression "e" can
723-
be either the character 'e' or 'E'.
724-
725-
true, false, and null are lowercase only (case-sensitive).
726-
727-
number = (int / "-0") [ frac ] [ exp ] ; decimal number
728-
frac = "." 1*DIGIT ; decimal fraction
729-
exp = "e" [ "-" / "+" ] 1*DIGIT ; decimal exponent
730-
true = %x74.72.75.65 ; true
731-
false = %x66.61.6c.73.65 ; false
732-
null = %x6e.75.6c.6c ; null
604+
number = (int / "-0") [ frac ] [ exp ]
605+
frac = "." 1*DIGIT
606+
exp = "e" [ "-" / "+" ] 1*DIGIT
607+
true = %x74.72.75.65
608+
false = %x66.61.6c.73.65
609+
null = %x6e.75.6c.6c
733610

734611
Table 10 lists filter expression operators in order of precedence
735612
from highest (binds most tightly) to lowest (binds least tightly).
@@ -1065,26 +942,7 @@ Example: $ applied to {"k": "v"} returns [{"k": "v"}]
1065942

1066943
2.4. Function Extensions
1067944

1068-
Beyond the filter expression functionality defined in the preceding
1069-
subsections, JSONPath defines an extension point that can be used to
1070-
add filter expression functionality: "Function Extensions".
1071-
1072-
This section defines the extension point and some function extensions
1073-
that use this extension point. While these mechanisms are designed
1074-
to use the extension point, they are an integral part of the JSONPath
1075-
specification and are expected to be implemented like any other
1076-
integral part of this specification.
1077-
1078-
A function extension defines a registered name (see Section 3.2) that
1079-
can be applied to a sequence of zero or more arguments, producing a
1080-
result. Each registered function name is unique.
1081-
1082-
A function extension MUST be defined such that its evaluation is free
1083-
of side effects, i.e., all possible orders of evaluation and choices
1084-
of short-circuiting or full evaluation of an expression containing it
1085-
MUST lead to the same result. (Note: Memoization or logging are not
1086-
side effects in this sense as they are visible at the implementation
1087-
level only -- they do not influence the result of the evaluation.)
945+
Function extensions add filter expression functionality. Each has a unique registered name, takes arguments, produces results, and must be side-effect free.
1088946

1089947
function-name = function-name-first *function-name-char
1090948
function-name-first = LCALPHA
@@ -1098,12 +956,6 @@ Example: $ applied to {"k": "v"} returns [{"k": "v"}]
1098956
logical-expr /
1099957
function-expr
1100958

1101-
Any function expressions in a query must be well-formed (by
1102-
conforming to the above ABNF) and well-typed; otherwise, the JSONPath
1103-
implementation MUST raise an error (see Section 2.1). To define
1104-
which function expressions are well-typed, a type system is first
1105-
introduced.
1106-
1107959
2.4.1. Type System for Function Expressions
1108960

1109961
Each parameter and the result of a function extension must have a
@@ -1621,80 +1473,17 @@ Function expressions must be well-typed:
16211473

16221474
2.6. Semantics of null
16231475

1624-
Note: JSON null is treated the same as any other JSON value, i.e., it
1625-
is not taken to mean "undefined" or "missing".
1476+
JSON null is treated as any other JSON value (not "undefined" or "missing").
16261477

16271478
2.6.1. Examples
16281479

1629-
JSON:
1630-
1631-
{"a": null, "b": [null], "c": [{}], "null": 1}
1480+
JSON: {"a": null, "b": [null], "c": [{}], "null": 1}
16321481

1633-
Queries:
1634-
1635-
+=================+========+===========+===========================+
1636-
| Query | Result | Result | Comment |
1637-
| | | Paths | |
1638-
+=================+========+===========+===========================+
1639-
| $.a | null | $['a'] | Object value |
1640-
+-----------------+--------+-----------+---------------------------+
1641-
| $.a[0] | | | null used as array |
1642-
+-----------------+--------+-----------+---------------------------+
1643-
| $.a.d | | | null used as object |
1644-
+-----------------+--------+-----------+---------------------------+
1645-
| $.b[0] | null | $['b'][0] | Array value |
1646-
+-----------------+--------+-----------+---------------------------+
1647-
| $.b[*] | null | $['b'][0] | Array value |
1648-
+-----------------+--------+-----------+---------------------------+
1649-
| $.b[?@] | null | $['b'][0] | Existence |
1650-
+-----------------+--------+-----------+---------------------------+
1651-
| $.b[?@==null] | null | $['b'][0] | Comparison |
1652-
+-----------------+--------+-----------+---------------------------+
1653-
| $.c[[email protected]==null] | | | Comparison with "missing" |
1654-
| | | | value |
1655-
+-----------------+--------+-----------+---------------------------+
1656-
| $.null | 1 | $['null'] | Not JSON null at all, |
1657-
| | | | just a member name string |
1658-
+-----------------+--------+-----------+---------------------------+
1659-
1660-
Table 17: Examples Involving (or Not Involving) null
1482+
Examples: $.a → null, $.a[0] → (empty), $.b[0] → null, $.b[?@] → null, $.b[?@==null] → null, $.c[[email protected]==null] → (empty), $.null → 1
16611483

16621484
2.7. Normalized Paths
16631485

1664-
A Normalized Path is a unique representation of the location of a
1665-
node in a value that uniquely identifies the node in the value.
1666-
Specifically, a Normalized Path is a JSONPath query with restricted
1667-
syntax (defined below), e.g., $['book'][3], which when applied to the
1668-
value, results in a nodelist consisting of just the node identified
1669-
by the Normalized Path. Note: A Normalized Path represents the
1670-
identity of a node _in a specific value_. There is precisely one
1671-
Normalized Path identifying any particular node in a value.
1672-
1673-
A nodelist may be represented compactly in JSON as an array of
1674-
strings, where the strings are Normalized Paths.
1675-
1676-
Normalized Paths provide a predictable format that simplifies testing
1677-
and post-processing of nodelists, e.g., to remove duplicate nodes.
1678-
Normalized Paths are used in this document as result paths in
1679-
examples.
1680-
1681-
Normalized Paths use the canonical bracket notation, rather than dot
1682-
notation.
1683-
1684-
Single quotes are used in Normalized Paths to delimit string member
1685-
names. This reduces the number of characters that need escaping when
1686-
Normalized Paths appear in strings delimited by double quotes, e.g.,
1687-
in JSON texts.
1688-
1689-
Certain characters are escaped in Normalized Paths in one and only
1690-
one way; all other characters are unescaped.
1691-
1692-
| Note: Normalized Paths are singular queries, but not all
1693-
| singular queries are Normalized Paths. For example, $[-3] is a
1694-
| singular query but is not a Normalized Path. The Normalized
1695-
| Path equivalent to $[-3] would have an index equal to the array
1696-
| length minus 3. (The array length must be at least 3 if $[-3]
1697-
| is to identify a node.)
1486+
Normalized Path: unique JSONPath representation of a node's location. Uses bracket notation with single quotes for member names.
16981487

16991488
normalized-path = root-identifier *(normal-index-segment)
17001489
normal-index-segment = "[" normal-selector "]"
@@ -1733,33 +1522,9 @@ Function expressions must be well-typed:
17331522
normal-index-selector = "0" / (DIGIT1 *DIGIT)
17341523
; non-negative decimal integer
17351524

1736-
Since there can only be one Normalized Path identifying a given node,
1737-
the syntax stipulates which characters are escaped and which are not.
1738-
So the definition of normal-hexchar is designed for hex escaping of
1739-
characters that are not straightforwardly printable, for example,
1740-
U+000B LINE TABULATION, but for which no standard JSON escape, such
1741-
as \n, is available.
1742-
17431525
2.7.1. Examples
17441526

1745-
+=============+=================+==========================+
1746-
| Path | Normalized Path | Comment |
1747-
+=============+=================+==========================+
1748-
| $.a | $['a'] | Object value |
1749-
+-------------+-----------------+--------------------------+
1750-
| $[1] | $[1] | Array index |
1751-
+-------------+-----------------+--------------------------+
1752-
| $[-3] | $[2] | Negative array index for |
1753-
| | | an array of length 5 |
1754-
+-------------+-----------------+--------------------------+
1755-
| $.a.b[1:2] | $['a']['b'][1] | Nested structure |
1756-
+-------------+-----------------+--------------------------+
1757-
| $["\u000B"] | $['\u000b'] | Unicode escape |
1758-
+-------------+-----------------+--------------------------+
1759-
| $["\u0061"] | $['a'] | Unicode character |
1760-
+-------------+-----------------+--------------------------+
1761-
1762-
Table 18: Normalized Path Examples
1527+
Examples: $.a → $['a'], $[1] → $[1], $[-3] → $[2] (array length 5), $.a.b[1:2] → $['a']['b'][1], $["\u000B"] → $['\u000b']
17631528

17641529
Appendix A. Collected ABNF Grammars
17651530

0 commit comments

Comments
 (0)