Structured Query Language for JSON (in Python)

I am working on a system to output a JSON file, and I use Python to parse the data and display it in the user interface (PySide). Now I would like to add filtering to this system, and I think, instead of writing a query system, if there was JSON (in Python), it would save me a lot of development time. I found this thread:

Is there a query language for JSON?

but it is more for the web system. Any ideas on the Python equivalent?

EDIT [for clarity]:

The format that I will generate is as follows:

{ "Operations": [ { "OpID": "0", "type": "callback", "stringTag1": "foo1", "stringTag2": "FooMsg", "Children": [...], "value": "0.000694053" }, { "OpID": "1", "type": "callback", "stringTag1": "moo1", "string2": "MooMsg", "Children": [...], "value": "0.000468427" } } 

Where "Children" can be nested arrays of the same thing (other operations). The system will be built so that users can add their own tags to the data. My hope was to have a query system that would allow users to define their own "filters", hence the question about the query language. If there was something that would allow me to do something like "SELECT * WHERE" type "==" callback "and return the required operations, that would be great.

Interestingly, the Pync proposal is interesting, I will give this look.

+6
source share
1 answer

I thought about this a bit, and I tend to something less specific, for example, to the "JSON Query Language" and is considered something more general. I recalled that I worked a bit with C #, that they had a somewhat common query system called LINQ to handle such problems.

It looks like Python has something similar to Pynq that supports basic queries, such as:

 filtered_collection = From(some_collection).where("item.property > 10").select_many() 

It even has some basic aggregation functions. Although I was not specific to JSON, I think this is at least a good starting point for requests.

+6
source

All Articles