Skip to content

Commit a8bace4

Browse files
committed
Add package level functions to docs and update CLI docs [skip ci]
1 parent bdbc677 commit a8bace4

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

docs/cli.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ optional arguments:
6262
File to write resulting objects to, as a JSON array. Defaults to the standard
6363
output stream.
6464
--no-type-checks Disables filter expression well-typedness checks.
65+
--strict Compile and evaluate JSONPath expressions with strict compliance with RFC 9535.
6566
```
6667

6768
## Global Options
@@ -191,6 +192,12 @@ _New in version 0.10.0_
191192

192193
Disables JSONPath filter expression well-typedness checks. The well-typedness of a filter expression is defined by RFC 9535.
193194

195+
#### `--strict`
196+
197+
_New in version 2.0.0_
198+
199+
Compile and evaluate JSONPath expressions with strict compliance with RFC 9535.
200+
194201
### `pointer`
195202

196203
Resolve a JSON Pointer against a JSON document. One of `-p`/`--pointer` or `-r`/`--pointer-file` must be given. `-p` being a JSON Pointer given on the command line as a string, `-r` being the path to a file containing a JSON Pointer.

docs/convenience.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Convenience Functions
2+
3+
These package-level functions use the default [JSONPathEnvironment](api.md#jsonpath.JSONPathEnvironment), `jsonpath.DEFAULT_ENV` when `strict=False`, or the preconfigured strict environment, `jsonpath.STRICT_ENV` when `strict=True`.
4+
5+
::: jsonpath.compile
6+
7+
handler: python
8+
9+
::: jsonpath.findall
10+
11+
handler: python
12+
13+
::: jsonpath.finditer
14+
15+
handler: python
16+
17+
::: jsonpath.findall_async
18+
19+
handler: python
20+
21+
::: jsonpath.finditer_async
22+
23+
handler: python
24+
25+
::: jsonpath.match
26+
27+
handler: python
28+
29+
::: jsonpath.query
30+
31+
handler: python

docs/quickstart.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ This page gets you started using JSONPath, JSON Pointer and JSON Patch wih Pytho
44

55
## `findall(path, data)`
66

7-
Find all values matching a JSONPath query using [`jsonpath.findall()`](api.md#jsonpath.JSONPathEnvironment.findall).
7+
Find all values matching a JSONPath query using [`jsonpath.findall()`](convenience.md#jsonpath.findall).
88

99
This function takes two arguments:
1010

11-
- `path`: a JSONPath query as a string (e.g., `"$.users[*].name"`)
11+
- `path`: a JSONPath query as a string (e.g. `"$.users[*].name"`)
1212
- `data`: the JSON document to query
1313

1414
It **always** returns a list of matched values, even if the path resolves to a single result or nothing at all.
1515

1616
The `data` argument can be:
1717

18-
- A Python [`Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping) (e.g., `dict`) or [`Sequence`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence) (e.g., `list`)
18+
- A Python [`Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping) (e.g. `dict`) or [`Sequence`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence) (e.g. `list`)
1919
- A JSON-formatted string
2020
- A file-like object containing JSON
2121

@@ -65,7 +65,7 @@ with open("users.json") as fd:
6565

6666
## `finditer(path, data)`
6767

68-
Use [`jsonpath.finditer()`](api.md#jsonpath.JSONPathEnvironment.finditer) to iterate over instances of [`jsonpath.JSONPathMatch`](api.md#jsonpath.JSONPathMatch) for every object in _data_ that matches _path_. It accepts the same arguments as [`findall()`](#findallpath-data), a query string and data from which to select matches.
68+
Use [`jsonpath.finditer()`](convenience.md#jsonpath.finditer) to iterate over instances of [`jsonpath.JSONPathMatch`](api.md#jsonpath.JSONPathMatch) for every object in _data_ that matches _path_. It accepts the same arguments as [`findall()`](#findallpath-data), a query string and data from which to select matches.
6969

7070
```python
7171
import jsonpath
@@ -109,7 +109,7 @@ The selected object is available from a [`JSONPathMatch`](api.md#jsonpath.JSONPa
109109

110110
## `compile(path)`
111111

112-
When you have a JSONPath query that needs to be matched against different data repeatedly, you can compile the path ahead of time using [`jsonpath.compile()`](api.md#jsonpath.JSONPathEnvironment.compile). It takes a query as a string and returns an instance of [`JSONPath`](api.md#jsonpath.JSONPath). `JSONPath` has `findall()` and `finditer()` methods that behave similarly to package-level `findall()` and `finditer()`, just without the `path` argument.
112+
When you have a JSONPath query that needs to be matched against different data repeatedly, you can compile the path ahead of time using [`jsonpath.compile()`](convenience.md#jsonpath.compile). It takes a query as a string and returns an instance of [`JSONPath`](api.md#jsonpath.JSONPath). `JSONPath` has `findall()` and `finditer()` methods that behave similarly to package-level `findall()` and `finditer()`, just without the `path` argument.
113113

114114
```python
115115
import jsonpath

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ nav:
5353
- JSON Pointers: "pointers.md"
5454
- Async Support: "async.md"
5555
- API Reference:
56+
- Package Level Functions: "convenience.md"
5657
- High Level API: "api.md"
5758
- Low Level API: "custom_api.md"
5859
- Exceptions: "exceptions.md"

0 commit comments

Comments
 (0)