You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6559f36
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/quickstart.md
+65-3Lines changed: 65 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ with open("users.json") as fd:
52
52
53
53
## `finditer(path, data)`
54
54
55
-
Use [`jsonpath.finditer()`](api.md#jsonpath.env.JSONPathEnvironment.finditer) to create an iterator which yields instances of [`jsonpath.JSONPathMatch`](api.md#jsonpath.JSONPathMatch) for every object in some data that matches a JSONPath. It accepts the same arguments as [`findall()`](#findall), a path string and _data_ from which to select matches.
55
+
Use [`jsonpath.finditer()`](api.md#jsonpath.env.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()`](#findall), a path string and data from which to select matches.
56
56
57
57
```python
58
58
import jsonpath
@@ -169,11 +169,11 @@ if match:
169
169
print(match.obj) # Sue
170
170
```
171
171
172
-
## `resolve(pointer, data)`
172
+
## `pointer.resolve(pointer, data)`
173
173
174
174
**_New in version 0.8.0_**
175
175
176
-
Resolve a [JSON Pointer](https://datatracker.ietf.org/doc/html/rfc6901). A JSON Pointer references a single object on a specific "path" in a JSON document. Here, _pointer_ can be a string representation of a JSON Pointer, or a list of parts that make up a pointer. _data_ can be a file-like object or string containing JSON formatted data, or equivalent Python objects.
176
+
Resolve a JSON Pointer ([RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901)) against some data. A JSON Pointer references a single object on a specific "path" in a JSON document. Here, _pointer_ can be a string representation of a JSON Pointer or a list of parts that make up a pointer. _data_ can be a file-like object or string containing JSON formatted data, or equivalent Python objects.
177
177
178
178
```python
179
179
from jsonpath import pointer
@@ -230,6 +230,68 @@ print(sue_score) # 0
230
230
231
231
See also [`JSONPathMatch.pointer()`](api.md#jsonpath.match.JSONPathMatch.pointer), which builds a [`JSONPointer`](api.md#jsonpath.JSONPointer) from a `JSONPathMatch`.
232
232
233
+
## `patch.apply(patch, data)`
234
+
235
+
**_New in version 0.8.0_**
236
+
237
+
Apply a JSON Patch ([RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902)) to some data. A JSON Patch defines update operation to perform on a JSON document.
238
+
239
+
_patch_ can be a string or file-like object containing a valid JSON Patch document, or an iterable of dictionaries.
240
+
241
+
_data_ is the target JSON document to modify. It can be a file-like object or string containing JSON formatted data, or equivalent Python objects. **_data_ is modified in-place**.
[JSONPatch](api.md#jsonpath.JSONPatch) also offers a builder API for constructing JSON patch documents. We use strings as JSON Pointers in this example, but existing [JSONPointer](api.md#jsonpath.JSONPointer)s are OK too.
Read about user-defined filter functions at [Function Extensions](advanced.md#function-extensions), or see how to make extra data available to filters with [Extra Filter Context](advanced.md#extra-filter-context).
Copy file name to clipboardExpand all lines: docs/syntax.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,6 +181,7 @@ This is a list of things that you might find in other JSONPath implementation th
181
181
- We don't support extension functions of the form `selector.func()`.
182
182
- We always return a list of matches from `jsonpath.findall()`, never a scalar value.
183
183
- We do not support arithmetic in filter expression.
184
+
- We don't allow dotted array indices. An array index must be surrounded by square brackets.
184
185
- 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.
185
186
186
187
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).
0 commit comments