structured query language for JSON (in Python)
You can also check out PythonQL, a query language extension to Python that handles SQL and JSON queries: pythonql
I notice this question was asked a few years ago but if someone else find this, here are some newer projects trying to address this same problem:
- ObjectPath (for Python and Javascript): http://objectpath.org/
- jsonpath (Python reimplementation of the Javascript equivalent): https://pypi.org/project/jsonpath/
- yaql: https://yaql.readthedocs.io/en/latest/readme.html
- pyjq (Python bindings for jq https://stedolan.github.io/jq/): https://pypi.org/project/pyjq/
- JMESPath: https://github.com/jmespath/jmespath.py
I personally went with pyjq
because I use jq
all the time for data exploration but ObjectPath seems very attractive and not limited to json.
I thought about this a little bit, and I lean towards something less specific such as a "JSON Query Language" and considered something more generic. I remembered from working with C# a bit that they had a somewhat generic querying system called LINQ for handling these sort of querying issues.
It looks as though Python has something similar called Pynq which supports basic querying such as:
filtered_collection = From(some_collection).where("item.property > 10").select_many()
It even appears to have some basic aggregation functions. While not being specific to JSON, I think it's a least a good starting point for querying.