Skip to content

Commit d5f0ff6

Browse files
committed
IETF JSONPath spec is now RFC 9535.
1 parent 04d4ddd commit d5f0ff6

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
<p align="center">
44
A flexible JSONPath engine for Python with JSON Pointer and JSON Patch.
5+
<br>
6+
We follow <a href="https://datatracker.ietf.org/doc/html/rfc9535">RFC 9535</a> and test against the <a href="https://github.com/jsonpath-standard/jsonpath-compliance-test-suite">JSONPath Compliance Test Suite</a>.
57
</p>
68

79
<p align="center">

docs/advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Add, remove or replace [filter functions](functions.md) by updating the [`functi
4343

4444
### Type System for Function Expressions
4545

46-
[Section 2.4.1](https://datatracker.ietf.org/doc/html/draft-ietf-jsonpath-base-21#section-2.4.1) of the IETF JSONPath Draft specification defines a type system for function expressions and requires that we check that filter expressions are well-typed. With that in mind, you are encouraged to implement custom filter functions by extending [`jsonpath.function_extensions.FilterFunction`](api.md#jsonpath.function_extensions.FilterFunction), which forces you to be explicit about the [types](api.md#jsonpath.function_extensions.ExpressionType) of arguments the function extension accepts and the type of its return value.
46+
[Section 2.4.1](https://datatracker.ietf.org/doc/html/rfc9535#name-type-system-for-function-ex) of RFC 9535 defines a type system for function expressions and requires that we check that filter expressions are well-typed. With that in mind, you are encouraged to implement custom filter functions by extending [`jsonpath.function_extensions.FilterFunction`](api.md#jsonpath.function_extensions.FilterFunction), which forces you to be explicit about the [types](api.md#jsonpath.function_extensions.ExpressionType) of arguments the function extension accepts and the type of its return value.
4747

4848
!!! info
4949

docs/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ $ json path -q "$.price_cap" -f /tmp/source.json --output result.json
189189

190190
_New in version 0.10.0_
191191

192-
Disables JSONPath filter expression well-typedness checks. The well-typedness of a filter expression is defined by the IETF JSONPath Draft specification.
192+
Disables JSONPath filter expression well-typedness checks. The well-typedness of a filter expression is defined by RFC 9535.
193193

194194
### `pointer`
195195

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
JSONPath is a mini language for selecting objects from data formatted in JavaScript Object Notation, or equivalent Python objects, like dictionaries and lists.
44

5-
Python JSONPath is a non-evaluating, read-only implementation of JSONPath, suitable for situations where JSONPath query authors are untrusted. We follow most of the [IETF JSONPath draft](https://datatracker.ietf.org/doc/html/draft-ietf-jsonpath-base-13). See [Notable differences](syntax.md#notable-differences) for a list of areas where we deviate from the standard.
5+
Python JSONPath is a non-evaluating, read-only implementation of JSONPath, suitable for situations where JSONPath query authors are untrusted. We follow most of [RFC 9535](https://datatracker.ietf.org/doc/html/rfc9535). See [Notable differences](syntax.md#notable-differences) for a list of areas where we deviate from the standard.
66

7-
Since version 0.8.0, we also include implementations of [JSON Pointer](pointers.md) ([RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901)) and [JSON Patch](api.md#jsonpath.JSONPatch) ([RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902)), plus methods for converting a [JSONPathMatch](api.md#jsonpath.JSONPathMatch) to a `JSONPointer`.
7+
We also include implementations of [JSON Pointer](pointers.md) ([RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901)) and [JSON Patch](api.md#jsonpath.JSONPatch) ([RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902)), plus methods for converting a [JSONPathMatch](api.md#jsonpath.JSONPathMatch) to a `JSONPointer`.
88

99
## Install
1010

docs/syntax.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JSONPath Syntax
22

3-
Python JSONPath's default syntax is an opinionated combination of JSONPath features from existing, popular implementations, and much of the [IETF JSONPath draft](https://datatracker.ietf.org/doc/html/draft-ietf-jsonpath-base-11). If you're already familiar with JSONPath syntax, skip to [notable differences](#notable-differences).
3+
Python JSONPath's default syntax is an opinionated combination of JSONPath features from existing, popular implementations and [RFC 9535](https://datatracker.ietf.org/doc/html/rfc9535). If you're already familiar with JSONPath syntax, skip to [notable differences](#notable-differences).
44

55
Imagine a JSON document as a tree structure, where each object (mapping) and array can contain more objects, arrays and scalar values. Every object, array and scalar value is a node in the tree, and the outermost object or array is the "root" node.
66

@@ -201,10 +201,9 @@ This is a list of things that you might find in other JSONPath implementation th
201201
- Python JSONPath is strictly read only. There are no update "selectors", but we do provide methods for converting `JSONPathMatch` instances to `JSONPointer`s, and a `JSONPatch` builder API for modifying JSON-like data structures using said pointers.
202202
- We don't attempt to handle JSON documents without a top-level array or object (or equivalent Python objects).
203203

204-
And this is a list of areas where we deviate from the [IETF JSONPath draft](https://datatracker.ietf.org/doc/html/draft-ietf-jsonpath-base-13).
204+
And this is a list of areas where we deviate from [RFC 9535](https://datatracker.ietf.org/doc/html/rfc9535).
205205

206206
- The root token (default `$`) is optional and paths starting with a dot (`.`) are OK. `.thing` is the same as `$.thing`, as is `thing`, `$[thing]` and `$["thing"]`.
207-
- Whitespace is mostly insignificant unless inside quotes.
208207
- The built-in `match()` and `search()` filter functions use Python's standard library `re` module, which, at least, doesn't support Unicode properties. We might add an implementation of `match()` and `search()` using the third party [regex](https://pypi.org/project/regex/) package in the future.
209208
- We don't require property names to be quoted inside a bracketed selection, unless the name contains reserved characters.
210209
- We don't require the recursive descent segment to have a selector. `$..` is equivalent to `$..*`.

jsonpath/env.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ def validate_function_extension_signature(
352352
) -> List[Any]:
353353
"""Compile-time validation of function extension arguments.
354354
355-
The IETF JSONPath draft requires us to reject paths that use filter
356-
functions with too many or too few arguments.
355+
RFC 9535 requires us to reject paths that use filter functions with
356+
too many or too few arguments.
357357
"""
358358
try:
359359
func = self.function_extensions[token.value]
@@ -452,10 +452,10 @@ async def getitem_async(self, obj: Any, key: object) -> Any:
452452
def is_truthy(self, obj: object) -> bool:
453453
"""Test for truthiness when evaluating JSONPath filter expressions.
454454
455-
In some cases, the IETF JSONPath draft requires us to test for
456-
existence rather than truthiness. So the default implementation returns
457-
`True` for empty collections and `None`. The special `UNDEFINED` object
458-
means that _obj_ was missing, as opposed to an explicit `None`.
455+
In some cases, RFC 9535 requires us to test for existence rather than
456+
truthiness. So the default implementation returns `True` for empty
457+
collections and `None`. The special `UNDEFINED` object means that
458+
_obj_ was missing, as opposed to an explicit `None`.
459459
460460
Arguments:
461461
obj: Any object.

jsonpath/function_extensions/arguments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def validate(
2020
) -> List[Any]:
2121
"""Generic validation of function extension arguments using introspection.
2222
23-
The IETF JSONPath draft requires us to reject paths that use filter
24-
functions with too many or too few arguments.
23+
RFC 9535 requires us to reject paths that use filter functions with too
24+
many or too few arguments.
2525
"""
2626
params = list(inspect.signature(func).parameters.values())
2727

0 commit comments

Comments
 (0)