JsonPath:按数组中任何数组中的值过滤

时间:2019-06-12 01:02:23

标签: java arrays json filter jsonpath

我尝试过滤以从具有扩展信息[SOURCE_OR_TARGET ==“ TARGET”]的“ * .. ou.subscriber”内的subscriberNumber中获取值,但是我的jsonpath无效。

我尝试的jsonpath:

$..ou[?(@.extendedInfo[0].value=="TARGET")].subscriber[0].subscriberNumber

结果,我想获得这个SubscriberNumber =“ 001”

JSON:

    {
    "customer": {
        "customerId": "34975213",
        "ou": [
            {
                "numberOfIDD": 0,
                "numberOfIR": 0,
                "ouId": 117482315,
                "subscriber": [
                    {
                        "status": 0,
                        "subscriberId": "90674393",
                        "subscriberNumber": "001"
                    }
                ],
                "responseCode": "FM120100000",
                "responseMsg": "Success",
                "extendedInfo": [
                    {
                        "name": "SOURCE_OR_TARGET",
                        "value": "BUCKET"
                    },
                    {
                        "name": "SOURCE_OR_TARGET",
                        "value": "TARGET"
                    }
                ]
            },
            {
                "numberOfIDD": 0,
                "numberOfIR": 0,
                "ouId": 21046276,
                "subscriber": [
                    {
                        "status": 65,
                        "subscriberId": "17404432",
                        "subscriberNumber": "002"
                    }
                ],
                "extendedInfo": [
                    {
                        "name": "SOURCE_OR_TARGET",
                        "value": "SOURCE"
                    }
                ]
            }
        ]
    }
}

谢谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您想要为带有扩展信息的订户节点过滤但不将其包括在订户中的错误的设计数据结构