Install & Compatibility
Where this runs
tested against v1.6.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.058s · 18.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.9s · import 0.058s · 19MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
JSONPath
✓ from bc_jsonpath_ng import JSONPath
✗ from jsonpath_ng import jsonpath
parse
✓ from bc_jsonpath_ng import parse
✗ from jsonpath_ng import parse
Fields
✓ from bc_jsonpath_ng import Fields
This quickstart demonstrates how to parse JSON data and extract values using JSONPath expressions. It shows basic selection, filtering, and how to retrieve both the value and the full path of matches.
import json
from jsonpath_ng import jsonpath, parse
data = {
"store": {
"book": [
{ "category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{ "category": "fiction",
"author": "E.B. White",
"title": "Charlotte's Web",
"price": 12.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}
# Example 1: Find all book titles
jsonpath_expr_titles = parse('$.store.book[*].title')
titles = [match.value for match in jsonpath_expr_titles.find(data)]
print(f"Book Titles: {titles}")
# Example 2: Find prices of books cheaper than 10
jsonpath_expr_cheap_books = parse('$.store.book[?price < 10].price')
cheap_prices = [match.value for match in jsonpath_expr_cheap_books.find(data)]
print(f"Prices of cheap books: {cheap_prices}")
# Example 3: Accessing full path of matches
jsonpath_expr_all_prices = parse('$.store..price')
for match in jsonpath_expr_all_prices.find(data):
print(f"Full path: {match.full_path}, Value: {match.value}")
jsonpath-ng --version
Debug
Known issues
gotchaThe PyPI package name is `bc-jsonpath-ng`, but the primary import is `jsonpath_ng`. This can be a common point of confusion for new users.fixAlways use `pip install bc-jsonpath-ng` for installation and `from jsonpath_ng import ...` for imports.
affects: All versions
gotchaThis library uses `` `this` `` (backtick-enclosed 'this') to reference the current object in JSONPath expressions, which differs from some other JSONPath implementations that use `@`.fixWhen writing JSONPath expressions, use `` `this` `` for self-referencing operations, e.g., `[?(`this`.price < 10)]`.
affects: All versions
breakingUsers of older Python versions should be aware that the `h2non/jsonpath-ng` fork (a related project, currently at v1.8.0) has dropped support for Python 3.8 and 3.9. While `bc-jsonpath-ng` v1.6.1 officially supports `>=3.8`, future updates or migrating to the `h2non` fork may require Python 3.10+.fixEnsure your project uses Python 3.10 or newer if planning to upgrade or switch to related, more recent JSONPath implementations.
affects: Potentially future versions of `bc-jsonpath-ng` or migrating to `jsonpath-ng` v1.8.0+ (h2non fork)
breakingIn related `jsonpath-ng` versions (e.g., v1.8.0 from the `h2non` fork), string serialization of fields and child precedence has been made more conservative (e.g., enclosing fields in quotation marks, preserving precedence with parentheses). This could impact round-trip parsing consistency if exact string representations were relied upon.fixReview any code that serializes JSONPath expressions or relies on specific string representations if upgrading to newer versions or switching forks. Test thoroughly for changes in output.
affects: Potentially future versions of `bc-jsonpath-ng` or migrating to `jsonpath-ng` v1.8.0+ (h2non fork)
Upgrade
Version history
1.6.1latest on PyPI · released Nov 26, 2023
Audit
Dependencies
No dependency data recorded yet.