{"id":2552,"library":"jsonpath-rw","title":"JSONPath-RW","description":"JSONPath-RW (jsonpath-rw) is a Python library that provides a robust and extended implementation of JSONPath, featuring a clear Abstract Syntax Tree (AST) for metaprogramming. As of its last release (1.4.0 in April 2015), it was primarily tested with Python 2.7, 3.4, 3.5, 3.6, and 3.7. While functional, its development is inactive, and more actively maintained and feature-rich alternatives like `jsonpath-ng` are now available, which merge its capabilities with `jsonpath-rw-ext` for modern Python versions.","status":"deprecated","version":"1.4.0","language":"python","source_language":"en","source_url":"https://github.com/kennknowles/python-jsonpath-rw","tags":["JSON","JSONPath","parsing","querying","data extraction"],"install":[{"cmd":"pip install jsonpath-rw","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for parsing JSONPath expressions.","package":"ply","optional":false},{"reason":"General utility.","package":"decorator","optional":false},{"reason":"Python 2/3 compatibility layer.","package":"six","optional":false}],"imports":[{"note":"The 'parse' function is directly exposed at the top-level `jsonpath_rw` package.","wrong":"from jsonpath_rw.jsonpath import parse","symbol":"parse","correct":"from jsonpath_rw import parse"},{"note":"The 'jsonpath' module (containing various expression types) is exposed at the top-level `jsonpath_rw` package.","wrong":"from jsonpath_rw.jsonpath import jsonpath","symbol":"jsonpath","correct":"from jsonpath_rw import jsonpath"}],"quickstart":{"code":"from jsonpath_rw import jsonpath, parse\n\n# Example JSON data\ndata = {'foo': [{'baz': 1}, {'baz': 2}, {'qux': 3}]}\n\n# Parse a JSONPath expression\njsonpath_expr = parse('foo[*].baz')\n\n# Find matches in the data\nmatches = [match.value for match in jsonpath_expr.find(data)]\nprint(f\"Extracted values: {matches}\")\n\n# Access full path of matches\nfull_paths = [str(match.full_path) for match in jsonpath_expr.find(data)]\nprint(f\"Full paths of matches: {full_paths}\")\n\n# Programmatic expression building\nfrom jsonpath_rw.jsonpath import Fields, Slice, Child\njsonpath_expr_direct = Fields('foo').child(Slice('*')).child(Fields('baz'))\nmatches_direct = [match.value for match in jsonpath_expr_direct.find(data)]\nprint(f\"Extracted values (programmatic): {matches_direct}\")","lang":"python","description":"This quickstart demonstrates how to parse a JSONPath expression, find matching values within a JSON object, and programmatically build expressions."},"warnings":[{"fix":"Migrate to `jsonpath-ng` for new projects or when upgrading Python versions. `pip install jsonpath-ng` and import `from jsonpath_ng import parse`.","message":"The `jsonpath-rw` library is no longer actively maintained. For modern Python applications (3.8+), consider using `jsonpath-ng` (jsonpath-ng.readthedocs.io), which merges the features of `jsonpath-rw` and `jsonpath-rw-ext` and offers active development and broader Python version support.","severity":"deprecated","affected_versions":"1.4.0 and earlier"},{"fix":"If filtering is required, install `jsonpath-rw-ext` (`pip install jsonpath-rw-ext`) and use its extended parser: `from jsonpath_rw_ext import parse`. Alternatively, switch to `jsonpath-ng` which includes these extensions by default.","message":"Filtering expressions (e.g., `[?()]`) are not directly supported by `jsonpath-rw`'s default parser. Attempting to use them will result in a `ParseError`. These extensions are available through the companion library `jsonpath-rw-ext`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Avoid running Python with optimization flags that strip docstrings when using `jsonpath-rw`. Ensure `PYTHONOPTIMIZE` is not set to `2` or similar values.","message":"The underlying parsing toolkit, PLY, does not work when Python docstrings are removed (e.g., by running Python with `PYTHONOPTIMIZE=2` or `python -OO`). This can lead to unexpected failures.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For Python 3.8 and newer, it is strongly recommended to use `jsonpath-ng` (which explicitly supports CPython 3.10 and higher) to ensure compatibility and receive ongoing updates.","message":"The `jsonpath-rw` library, as of version 1.4.0, was primarily tested with Python versions up to 3.7. While it might function on newer Python versions, active development and testing for compatibility beyond 3.7 is not ongoing. There have been reports of build failures with newer `setuptools` versions.","severity":"gotcha","affected_versions":"1.4.0 and earlier, particularly with Python 3.8+ or recent `setuptools`."}],"env_vars":null,"search_vec":"'1.4.0':37 '2.7':47 '2015':40 '3.4':48 '3.5':49 '3.6':50 '3.7':52 'abstract':26 'activ':61 'altern':67 'april':39 'ast':29 'avail':74 'capabl':78 'clear':25 'data':92 'develop':56 'ext':83 'extend':19 'extract':93 'featur':23,65 'feature-rich':64 'function':54 'implement':20 'inact':58 'json':88 'jsonpath':2,5,8,22,70,81,89 'jsonpath-ng':69 'jsonpath-rw':1,4,7 'jsonpath-rw-ext':80 'last':35 'librari':13 'like':68 'maintain':62 'merg':76 'metaprogram':31 'modern':85 'ng':71 'pars':90 'primarili':43 'provid':15 'python':12,46,86 'queri':91 'releas':36 'rich':66 'robust':17 'rw':3,6,9,82 'syntax':27 'test':44 'tree':28 'version':87","created_at":"2026-04-11T01:32:55.581871+00:00","updated_at":"2026-04-16T15:56:52.790373+00:00","problems":[{"fix":"Ensure the package is installed using pip. The correct package name for installation is `jsonpath-rw`, but the import statement uses `jsonpath_rw`. \n```bash\npip install jsonpath-rw\n```\nThen import using:\n```python\nfrom jsonpath_rw import jsonpath, parse\n```","cause":"The `jsonpath-rw` package is not installed in your Python environment, or there's a typo in the import statement.","error":"ModuleNotFoundError: No module named 'jsonpath-rw'"},{"fix":"Install the package using pip. \n```bash\npip install jsonpath-rw\n```\nIf already installed, verify your Python environment's paths or consider using a virtual environment. The import statement should be `from jsonpath_rw import jsonpath, parse`.","cause":"This error is typically seen in older Python environments or when the package is not installed correctly. It's the `ModuleNotFoundError` equivalent for `import` statements.","error":"ImportError: No module named jsonpath_rw"},{"fix":"For advanced filter expressions, use `jsonpath-rw-ext` or the more modern and actively maintained `jsonpath-ng` library, which provides extended JSONPath capabilities and merges `jsonpath-rw` and `jsonpath-rw-ext`.\n```bash\npip install jsonpath-ng\n```\nThen, for `jsonpath-ng`:\n```python\nfrom jsonpath_ng import jsonpath, parse\n# Or for extended features\nfrom jsonpath_ng.ext import parse\n\njsonpath_expr = parse('$.items[?(@.name = \"example\")]')\n```\nIf you must use `jsonpath-rw`, simplify your JSONPath expression to avoid advanced filters.","cause":"The `jsonpath-rw` library, particularly version 1.4.0, has limited or no native support for advanced filter expressions using `?` as specified in some JSONPath standards. Users often encounter this when trying to use filter conditions that are not recognized by `jsonpath-rw`'s parser.","error":"jsonpath_rw.lexer.JsonPathLexerError: Error on line X, col Y: Unexpected character: ?"},{"fix":"Ensure you are importing from the correct library and using its API. The `jsonpath-rw` library exposes its core functionality, including the `parse` function, directly from the `jsonpath_rw` module.\n```python\nfrom jsonpath_rw import jsonpath, parse\n\n# To parse an expression:\njsonpath_expr = parse('your.json.path')\n\n# To find matches:\nmatches = jsonpath_expr.find(your_data)\n```\nIf you intended to use a different `jsonpath` library, ensure it's installed and imported correctly according to its documentation.","cause":"This error usually occurs when a user incorrectly imports a module named `jsonpath` (which might be a different, less commonly used library, or even a local file) and expects it to have the `jsonpath` attribute from `jsonpath-rw`'s API, or when they try to call `jsonpath.jsonpath()` directly instead of using the `parse` function from `jsonpath_rw`.","error":"AttributeError: module 'jsonpath' has no attribute 'jsonpath'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.4.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/kennknowles/python-jsonpath-rw","docs":null,"changelog":null,"pypi":"https://pypi.org/project/jsonpath-rw/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}