ObjectPath is a Python library that provides an agile query language for semi-structured data, particularly JSON. It allows for powerful querying similar to XPath or JSONPath, incorporating arithmetic calculations, comparisons, and built-in functions. The current version is 0.6.1, released in November 2018. The original Python implementation (adriank/ObjectPath) is currently not actively maintained, which is an important consideration for new projects.
pip install objectpathVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create an ObjectPath Tree from a JSON-like Python dictionary and execute basic queries to extract data. It shows how to retrieve all authors, filter books by price, and access specific nested properties.
For new projects, evaluate alternatives like `objectpath-ng` (installable via `pip install objectpath-ng`) or other modern JSON querying libraries. If continuing with `objectpath`, be aware of the lack of ongoing support for bug fixes or new features.
Always convert the generator to a list, tuple, or iterate over it directly if you need to consume all results or reuse the collection. Example: `results = list(tree.execute('$.path'))`.Refer to the ObjectPath Reference documentation for detailed syntax and operator usage. Test complex queries thoroughly with sample data.
Add `from objectpath import Tree` at the beginning of your script.
Convert the generator to a list or tuple first: `results = list(tree.execute('$.path'))`.Double-check the query against the ObjectPath reference documentation for correct syntax. Pay attention to quotation marks for string literals, array filtering conditions, and operator precedence.
No dependency data recorded yet.