{"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":"en","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,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}