Registry / data / bc-jsonpath-ng

bc-jsonpath-ng

JSON →
library1.6.1pypypi✓ verified 24d ago

bc-jsonpath-ng is a robust and extended implementation of JSONPath for Python, aiming for standard compliance. It includes arithmetic and binary comparison operators and provides a clear Abstract Syntax Tree (AST) for metaprogramming, merging functionalities from `jsonpath-rw` and `jsonpath-rw-ext`. The current version is 1.6.1, and it receives active maintenance and updates.

pip install bc-jsonpath-ng
INSTALL
IMPORT
SIG · BC-JSONPATH-NG
B
bc-jsonpath-ng
datapythonv1.6.1
Install
1.9s avg
Import
58ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.058s · 18.4MB
glibc
py 3.103.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.
fix
Always 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 `@`.
fix
When 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+.
fix
Ensure 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.
fix
Review 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.

Agent activity
34 hits · last 30 days
node
28
Amazon
1
OpenAI (training)
1
Resources
bc-jsonpath-ng — pip install bc-jsonpath-ng · libregistry