python语言结构化语言_JSON的结构化查询语言(在Python中)

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

but that's more for a Web-based system. Any ideas on a Python equivalent?

EDIT [for clarity]:

The format the data that I'll be generating is like this:

{

"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' could be nested arrays of the same thing (other operations). The system will be built to allow users to add their own tags as well to the data. My hope was to have a querying system that would allow users to define their own 'filters' as well, hence the question about the querying language. If there was something that would let me do something like "SELECT * WHERE "type" == "callback" and get the requisite operations back, that would be great.

The suggestion of Pync is interesting, I'll give that a look.

解决方案

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值