The **rjsonpath** package provides an implementation of the JSONPath query language for R. JSONPath is an XPath-like syntax for selecting elements from JSON data structures.

Details

The main entry point is [json_path()], which evaluates a JSONPath expression against a JSON object read with [read_json()]. It supports common JSONPath features, including:

- **Property access** via `$.prop` and nested properties - **Array indices and slices** such as `$.items[0]`, `$.items[1:3]` - **Wildcards** (`*`) for properties and array elements - **Recursive descent** using `..` - **Filters** with `?()` expressions, e.g. `?(@.price < 10)` - **Length‑based expressions** like `(@.length-1)`

Workflow

Typical usage is:

1. Read JSON from a file or connection with [read_json()]. 2. Apply a JSONPath query with [json_path()] to select elements. 3. Optionally set `simplify = TRUE` to coerce simple list results to atomic vectors.

Strict vs. lenient paths

By default, [json_path()] requires paths to start with `"$"` and treats numeric indices as zero-based (JSON-style). You can relax these behaviours using the `strict` and `zero_index` arguments.

See also

Author

Maintainer: Ben Moore ben@blm.io