jsonpath-mojo
A fast JSONPath query engine, API-compatible with the
jsonpath-ng package (the
jsonpath_ng.ext extended dialect), powered by a clean-room Mojo kernel —
with a vendored pure-Python engine for platforms without a native build (including Windows — tested there in CI: windows-fallback).
from jsonpath_mojo import find
data = {"store": {"book": [{"title": "Sayings", "price": 8.95},
{"title": "Sword", "price": 12.99}]}}
find("$.store.book[*].title", data) # [('Sayings', 'store.book.[0].title'),
# ('Sword', 'store.book.[1].title')]
find("$.store.book[?(@.price < 10)]", data) # filter scripts
find("$..price", data) # recursive descent
find(expr, data) returns the same (value, str(full_path)) sequence as
[(m.value, str(m.full_path)) for m in jsonpath_ng.ext.parse(expr).find(data)]
— same values, same order, same path rendering, verified element-for-element
by the differential test suite on both backends.
- Same results: the suite runs every query against the published
jsonpath_ng==1.7.0oracle and asserts exact sequence parity — plus exception-type parity for the error contract (parse errors raisejsonpath_mojo.JsonPathError; runtime errors raise the same builtinTypeError/KeyError/IndexError/ValueError/NotImplementedErrorthe oracle raises). - Much faster: a native expression parser + evaluator instead of a PLY parser rebuilt per call — 49x faster at 100-book documents, 3.6x at 2k, 1.7x at 20k (Apple M4 Max; full method and numbers below).
- No toolchain needed: per-platform wheels ship the compiled kernel. Everywhere else the package transparently uses its pure-Python engine (which is itself ~2-28x faster than the oracle on these datasets).
- Force the fallback with
JSONPATH_MOJO_DISABLE_NATIVE=1; inspect the active backend withjsonpath_mojo.backend_info().
Supported syntax
- child steps:
$.a,$['a'],$.a.b, dot-number children$.a.0 - field unions:
$['a', 'b'](expression order, duplicates repeated); a quoted'*'— alone or in a union — is a wildcard - wildcards:
$.*(object values),$[*](sequence elements; see README in the repo for the exact non-list truth table) - recursive descent:
$..a,$..*,$..[0],$..['a'](DFS pre-order) - index:
$.a[0],$.a[-1] - slices:
$.a[1:5:2],$.a[::-1](Python slice semantics) - filters:
$.a[?(@.x > 2)]with== != < <= > >=,&conjunctions, existence tests?(@.x), arith (+ - *) on the left side, literals (numbers, quoted strings,true/false, bare words) on the right, and@paths with fields/indexes/slices/wildcards
Expressions outside this grammar (or data outside the JSON domain — non-string
dict keys, NaN/Infinity, tuples, custom objects) are handled with identical
results: grammar gaps raise JsonPathError, non-JSON data transparently
reroutes to the pure-Python engine. Currently unsupported oracle features:
?(...) filters nested inside a filter path (e.g. ?(@.a[?(@ > 1)] == 2)),
and sorting/~ regex extensions.
Benchmarks
Method (see benchmarks/bench_jsonpath.py in the repository): store-shaped
JSON documents (100 / 2,000 / 20,000 book records) and a 14-query battery
covering the supported scope. Each cell runs jsonpath_ng.ext.parse(expr). find(data) per query against jsonpath_mojo.find(expr, data). COLD = first
battery call (includes one-time parser setup); WARM = median of 5 battery
runs. Correctness is asserted before timing.
Measured on Apple M4 Max, macOS 26.6.2, Python 3.12.14, jsonpath_ng 1.7.0, Mojo 1.1.0, 2026-09-19:
| dataset | backend | cold (s) | warm (s) | speedup (warm) |
|---|---|---|---|---|
| 100 books | oracle jsonpath_ng | 0.1568 | 0.1993 | 1.0x |
| jsonpath-mojo native | 0.0050 | 0.0041 | 49.2x | |
| jsonpath-mojo fallback | 0.0078 | 0.0071 | 27.9x | |
| 2,000 books | oracle jsonpath_ng | 0.3209 | 0.2750 | 1.0x |
| jsonpath-mojo native | 0.0728 | 0.0766 | 3.6x | |
| jsonpath-mojo fallback | 0.1411 | 0.1353 | 2.0x | |
| 20,000 books | oracle jsonpath_ng | 1.7522 | 1.4909 | 1.0x |
| jsonpath-mojo native | 0.7877 | 0.8738 | 1.7x | |
| jsonpath-mojo fallback | 1.4734 | 1.2992 | 1.1x |
The oracle rebuilds its PLY parser on every parse() call (~7 ms), so small
and medium documents are dominated by expression parsing — where the native
kernel and even the pure-Python engine win overwhelmingly. On very large
documents the evaluation itself dominates; the native pipeline
(json.dumps → kernel parse+eval → path resolution) still leads, and result
correctness is identical either way.
Source, tests, and development: https://github.com/thyn-ai/mojo-kernels
License: Apache-2.0, © 2026 Algenta
Metadata
Release files for jsonpath-mojo 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsonpath_mojo-0.2.5-py3-none-manylinux_2_35_x86_64.whl | Python 3 | none | Linux glibc 2.35+ x86-64 | Details for jsonpath_mojo-0.2.5-py3-none-manylinux_2_35_x86_64.whl |
| jsonpath_mojo-0.2.5-py3-none-macosx_14_0_arm64.whl | Python 3 | none | macOS 14.0+ ARM64 | Details for jsonpath_mojo-0.2.5-py3-none-macosx_14_0_arm64.whl |
| jsonpath_mojo-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for jsonpath_mojo-0.2.5-py3-none-any.whl |
Total release size: 2.0 MB
Release files / jsonpath_mojo-0.2.5-py3-none-manylinux_2_35_x86_64.whl
| Download URL | jsonpath_mojo-0.2.5-py3-none-manylinux_2_35_x86_64.whl |
|---|---|
| Size | 870.9 kB |
| Tags | Linux glibc 2.35+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
870a3928d048f9dbf5a8f3064a1907ed27caed87ce608022a39976b686ed80fb
|
|
BLAKE2b-256 checksum How to use checksums |
b980febb49973023a6da6afcb5f7fbaaa887d6b1d5176ea1f9fd422210a22579
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / jsonpath_mojo-0.2.5-py3-none-macosx_14_0_arm64.whl
| Download URL | jsonpath_mojo-0.2.5-py3-none-macosx_14_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Python 3 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
58f8ec308e862746fe4a73909ba01f394a9cbbcd2442e1b5105625745b3d88d3
|
|
BLAKE2b-256 checksum How to use checksums |
54a40f47c79e8b8b8f83a01dcd4cfac8db643ee94a296bdfc37cf847fda1cff7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / jsonpath_mojo-0.2.5-py3-none-any.whl
| Download URL | jsonpath_mojo-0.2.5-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
133087df00b1bb8b2d888021a774d31caed92e8cdd7a3e42b399c654ac6012d2
|
|
BLAKE2b-256 checksum How to use checksums |
7196ef789e7193b3b7876d15e7c272299333b60ddb28f2265f08ccf68fff82e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for jsonpath-mojo 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.