Skip to content

Commit fc44327

Browse files
committed
docs: fake root identifier
1 parent baafec1 commit fc44327

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/syntax.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ Filter expressions can call predefined [function extensions](functions.md) too.
162162
$.categories[?count(@.products.*) >= 2]
163163
```
164164

165+
### Fake root (`^`)
166+
167+
**_New in version 0.11.0_**
168+
169+
This non-standard "fake root" identifier behaves like the standard root identifier (`$`), but wraps the target JSON document in a single-element array, so as to make it selectable with a filter selector.
170+
171+
```text
172+
^[?length(categories) > 0]
173+
```
174+
165175
### Union (`|`) and intersection (`&`)
166176

167177
Union (`|`) and intersection (`&`) are similar to Python's set operations, but we don't dedupe the matches (matches will often contain unhashable objects).
@@ -209,3 +219,4 @@ And this is a list of features that are uncommon or unique to Python JSONPath.
209219
- `#` is the current key/property or index identifier when filtering a mapping or sequence.
210220
- `_` is a filter context selector. With usage similar to `$` and `@`, `_` exposes arbitrary data from the `filter_context` argument to `findall()` and `finditer()`.
211221
- `~` is a "keys" or "properties" selector.
222+
- `^` is a "fake root" identifier. It is equivalent to `$`, but wraps the target JSON document in a single-element array, so the root value can be conditionally selected with a filter selector.

0 commit comments

Comments
 (0)