Skip to main content

Library for matching large numbers of JSONPath expressions simultaniously

Project description

JSON Hyperscan

A small, fast library that builds a simple "hyperscan" automaton to match many JSONPath (RFC9535-style) expressions against JSON documents. The project provides a compact in-process matcher that aims for parity with jsonpath_rfc9535.

Key features

  • Add many JSONPath selectors and build a matching automaton
  • Query JSON documents for matches efficiently
  • Support for field, child, descendant, index, slice and filter selectors
  • Small, well-tested core implementation located at src/json_hyperscan/json_hyperscan.py

Quick start

Install (developer/test environment)

This project uses modern Python tooling. Create a virtual environment and install dev dependencies listed in pyproject.toml.

python -m venv .venv
source .venv/bin/activate
pip install -U pip

# Recommended (fast, reproducible): install uv and use it to manage deps
pip install uv
# Create a venv and install project + dev deps using uv's pip frontend
uv pip install -e .[dev]

Note about the compliance test-suite

The project includes the JSONPath compliance tests as a git submodule at tests/jsonpath-compliance-test-suite. CI checks out submodules automatically, but if you're running tests locally you may need to initialize it first:

git submodule update --init --recursive

Or, if you only need runtime installation (no dev extras):

pip install -e .

Basic usage

A minimal example using the public API in JSONHyperscan:

from json_hyperscan import JSONHyperscan

hs = JSONHyperscan()
hs.add_pattern('$.store.book[*].author')
hs.add_pattern('$..title')

doc = {
	"store": {
		"book": [
			{"author": "Nigel Rees", "title": "Sayings of the Century"},
			{"author": "Evelyn Waugh", "title": "Sword of Honour"}
		]
	}
}

matches = list(hs.iter_matches(doc))
for m in matches:
	print(m)

License

See the LICENSE file in the repository.

Acknowledgements

This project uses jsonpath_rfc9535 for parsing and some tests compare output to other JSONPath implementations. See pyproject.toml for the dependency list used in development and testing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

json_hyperscan-0.1.0.tar.gz (70.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

json_hyperscan-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file json_hyperscan-0.1.0.tar.gz.

File metadata

  • Download URL: json_hyperscan-0.1.0.tar.gz
  • Upload date:
  • Size: 70.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for json_hyperscan-0.1.0.tar.gz
Algorithm Hash digest
SHA256 06f17155d31f9b0c4430c7082d60d6550d18aa62b83b7ef96cbeced28ec41b20
MD5 62f59384752e6de08e6869317dc01e57
BLAKE2b-256 56088358cf0e54e59b2ff082c6be874bf7d8b5f6a1a5beda032b8e180b1e844b

See more details on using hashes here.

Provenance

The following attestation bundles were made for json_hyperscan-0.1.0.tar.gz:

Publisher: publish.yml on captonsnake/json_hyperscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file json_hyperscan-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: json_hyperscan-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for json_hyperscan-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 742c4d9604dd6138d2f02b7841cc0a5be5af0f9966e10a7ba798876083471aef
MD5 6794f0488ac6cd1a500ead110f06fcdd
BLAKE2b-256 51a27566818f176d18d1cf59b2cc7810570c14bc9b0c332364a343b0f4eec0e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for json_hyperscan-0.1.0-py3-none-any.whl:

Publisher: publish.yml on captonsnake/json_hyperscan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page