jsonpath-ng

A standard-compliant JSONPath implementation for Python with arithmetic operators, AST manipulation, and in-place updates.

Library
PyPI
v1.10.0
735 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
83 /100 Excellent
Development Activity 100
Maintenance 72
Community 72
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
72 /100 Good
Architecture 78
Code Quality 74
Innovation 62
Learning Curve 75

jsonpath-ng is a full JSONPath language implementation for Python, not just a regex-based matcher. It merges the earlier jsonpath-rw and jsonpath-rw-ext projects into a single library, so expressions are first-class parsed objects that can be inspected, transformed, printed, and extended rather than opaque strings.

Beyond simple find() lookups, the library supports updating and removing matched nodes in place, filtering data by predicate, automatic ID generation for unlabeled records, and an extended syntax (via jsonpath_ng.ext) that adds arithmetic, filter, string, and sort operators on top of the base grammar. A bundled jsonpath_ng CLI script lets you run JSONPath queries against JSON files or stdin without writing any Python.

What You Get

  • Standard JSONPath parsing - an LALR parser (built on PLY) turns JSONPath strings into a typed AST instead of matching with fragile regexes.
  • Extended operator syntax - jsonpath_ng.ext adds arithmetic, comparison (==, !=, <, >, <=, >=, =~), boolean filters, sort direction, and string functions like `len` and `keys`.
  • In-place mutation - update(), update_or_create(), and filter() let you rewrite or strip matched values directly in the source data structure.
  • Path-aware matches - every DatumInContext result tracks its full_path, so you can print, compare, or reconstruct the exact path that produced a value.
  • Automatic ID assignment - setting jsonpath.auto_id_field backfills a chosen field with a generated JSONPath-based ID for any record missing one.
  • Bundled CLI - the jsonpath_ng console script runs a JSONPath expression against files or stdin from the shell, no Python glue code required.

Common Use Cases

  • Extracting nested API fields - a service pulls specific values out of deeply nested third-party JSON responses without writing manual key-chasing code.
  • Config and manifest querying - tooling that needs to read or validate specific paths inside JSON/YAML-derived config trees uses jsonpath-ng instead of ad hoc dict traversal.
  • Bulk transforming JSON documents - a data pipeline uses update()/filter() to redact, normalize, or strip fields across many documents matching one path expression.
  • Building JSONPath-driven query tools - applications that expose a JSONPath query box to end users (e.g. API explorers, log viewers) embed jsonpath-ng as the execution engine.

Under The Hood

Architecture jsonpath-ng is organized as a small compiler pipeline: lexer.py tokenizes a JSONPath string using a PLY-based JsonPathLexer, parser.py’s JsonPathParser turns the token stream into an AST of JSONPath subclasses defined in jsonpath.py (Root, This, Fields, Slice, Index, Child, Descendants, Where, Union, and more), and each node implements a shared interface (find, update, filter, child) so any AST node can be evaluated against arbitrary JSON data or composed into a larger expression. Results are wrapped in DatumInContext, which threads the traversal path back through nested calls so full_path can be reconstructed after the fact. The jsonpath_ng.ext package layers an ExtendedJsonPathLexer/ExtendedJsonPathParser on top of the base grammar, adding arithmetic, filter, iterable, and string operator modules without modifying the core AST classes, and jsonpath_ng/bin/jsonpath.py provides a thin CLI wrapper around parse() and find().

Tech Stack The library is pure Python (3.10+ per CI and classifiers) with a single runtime dependency family: a vendored/forked _ply package (Python Lex-Yacc) used for lexing and LALR parsing, rather than a hand-rolled regex matcher. Packaging is done with classic setuptools (setup.py), tests run under pytest with tox orchestrating the version matrix, and CI (.github/workflows/ci.yml) exercises Python 3.10 through 3.14 (including prereleases) on every push and PR via GitHub Actions, plus a separate CodeQL workflow for static security scanning.

Code Quality The tests/ directory contains dedicated suites for the lexer, parser, core JSONPath semantics, the jsonpath-rw-ext extension surface, creation/mutation behavior, exceptions, and round-tripping expressions back to strings — over a thousand lines of tests total, run with pytest and configured in pyproject.toml to escalate warnings to errors (with a narrow exception for a known _ply ResourceWarning). Code style favors explicit AST classes over generic dict/regex hacks, and JsonPathLexerError/JsonPathParserError give typed, specific error paths for malformed expressions rather than silently swallowing them. There’s no separate linter/formatter config visible in the repo, and the multi-version CI matrix is the main quality gate beyond the test suite itself.

What Makes It Unique Unlike simpler dict-traversal or regex-based JSONPath shims, jsonpath-ng treats JSONPath as a real grammar with a proper lexer/parser and a fully composable AST — expressions are objects you can build programmatically (Fields('foo').child(Slice('*'))), inspect, and extend, not opaque strings evaluated by a black box. Its merge of jsonpath-rw and jsonpath-rw-ext into one project, plus support for in-place update/filter mutation and full-path-aware results, goes beyond what most other Python JSONPath implementations offer, which are typically read-only.

Used by 7 apps in this directory

Python
88%
Apache 2.0

Apache Airflow

Data Engineering

47,133

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
64
Dependency
Built with
Python 88%
Updated today
Python
79%
Apache 2.0

changedetection.io

Monitoring

34,864

Self-hosted website change detection with AI-powered smart alerts, browser automation, price tracking, and 85+ notification channels.

View details
92
Repo Health
80
Technical
68
Dependency
Built with
Python 79%
Updated yesterday
Python
45%
GPL 3.0

MaxKB

AI Development · Knowledge Management

22,931

Build enterprise-grade AI agents with RAG, workflows & multi-modal support

View details
92
Repo Health
68
Technical
66
Dependency
Built with
Python 45%
Vue 37%
TypeScript 17%
Updated today
Python
49%
Other

Arize Phoenix

Analytics · Devops · Monitoring

11,770

Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.

View details
92
Repo Health
88
Technical
67
Dependency
Built with
Python 49%
TypeScript 43%
Updated today
Python
49%
Other

Arize Phoenix

Analytics · Devops · Monitoring

11,770

Open-source AI observability platform for tracing, evaluating, and debugging LLM applications with built-in intelligence and MCP support.

View details
92
Repo Health
88
Technical
67
Dependency
Built with
Python 49%
TypeScript 43%
Updated today
Python
94%
Apache 2.0

SWIRL

Data Engineering · Databases · Search

3,047

Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.

View details
60
Repo Health
83
Technical
65
Dependency
Built with
Python 94%
Updated 2 weeks ago
Python
70%
AGPL 3.0

Tracecat

AI Agents · Automation · Security

3,830

Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.

View details
89
Repo Health
88
Technical
66
Dependency
Built with
Python 70%
TypeScript 29%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers