根据搜索条件过滤json数组(有数百万项)

时间:2015-10-08 10:57:51

标签: java json search filter

根据一些不断变换的搜索条件,我无法找到过滤json数组(有数百万项)的最佳方法。

例如:根据region_id和pool_id

查找所有项目

json数组格式如下

[
    {
        "url": "webservices/rest/resources/1/", 
        "id": 1, 
        "name": "con A", 
        "is_parent": 1, 
        "account_id": 1, 
        "pool_id": 4, 
        "region_id": 5, 
        "market_id": 1, 
        "baseline_type": "Type 1", 
        "is_producer": 0, 
        "utilisation_type": 0, 
        "forecasting_algorithm": "Clipped nominal capacity", 
        "availability_protocol": null, 
        "communication_protocol": "OPC", 
        "activation_protocol": [
            " Demo"
        ], 
        "installed_capacity": 2000.0, 
        "nominal_capacity": 1000.0, 
        "positive_tolerance": 300.0, 
        "negative_tolerance": 300.0, 
        "capacity_fee": 20.0, 
        "energy_fee": 20.0, 
        "activation_fee": 10.0, 
        "parent_resource": null
    }, 
    {
        "url": "webservices/rest/resources/2/", 
        "id": 2, 
        "name": "con B", 
        "is_parent": 1, 
        "account_id": 2, 
        "pool_id": 1, 
        "region_id": 4, 
        "market_id": 1, 
        "baseline_type": "Type 1 DW", 
        "is_producer": 1, 
        "utilisation_type": 0, 
        "forecasting_algorithm": "Clipped nominal capacity", 
        "availability_protocol": null, 
        "communication_protocol": " Demo", 
        "activation_protocol": [
            " Demo"
        ], 
        "installed_capacity": 3000.0, 
        "nominal_capacity": 1000.0, 
        "positive_tolerance": 300.0, 
        "negative_tolerance": 300.0, 
        "capacity_fee": 20.0, 
        "energy_fee": 20.0, 
        "activation_fee": 10.0, 
        "parent_resource": null
    },
.
.
. // million items

]

我尝试在java中使用以下api

  • 用于将json转换为java对象的Jackson api。
  • 用于过滤java对象的Google Guava api。

过滤json数据是最好的程序吗?如果没有,请咨询。

0 个答案:

没有答案