JSONPath:保留过滤值的内容

时间:2018-01-23 14:14:17

标签: jsonpath rest-assured-jsonpath

以下是我试图提取匹配过滤器内容的JSON内容

{
        "results": [{
                "individualProviderId": "P1",
                "locations": [{
                        "addressInfo": {
                            "city": "Pembroke Pines",
                            "county": "Broward",
                            "state": "FL",
                            "zip": "33026"
                        },
                        "plans": [{
                                "networkId": "N1",
                                "tiering": [{
                                        "policyPlanID": "PP1"
                                    }, {
                                        "policyPlanID": "PP2"
                                    }, {
                                        "policyPlanID": "PP3"
                                    }, {
                                        "policyPlanID": "PP4"
                                    }
                                ]
                            }, {
                                "networkId": "N2",
                                "tiering": [{
                                        "policyPlanID": "PP5"
                                    }, {
                                        "policyPlanID": "PP8"
                                    }
                                ]
                            }, {
                                "networkId": "N3",
                                "tiering": [{
                                        "policyPlanID": "PP1"
                                    }, {
                                        "policyPlanID": "PP9"
                                    }
                                ]
                            }, {
                                "networkId": "N4",
                                "tiering": [{
                                        "policyPlanID": "PP7"
                                    }
                                ]
                            }
                        ]
                    }, {
                        "addressInfo": {
                            "city": "Pembroke Pines2",
                            "county": "Broward2",
                            "state": "FL2",
                            "zip": "330262"
                        },
                        "plans": [{
                                "networkId": "N2",
                                "tiering": [{
                                        "policyPlanID": "PP5"
                                    }
                                ]
                            }

                        ]
                    }

                ]
            },
            {
                "individualProviderId": "P2",
                "locations": [{
                        "addressInfo": {
                            "city": "Pembroke Pines",
                            "county": "Broward",
                            "state": "FL",
                            "zip": "33026"
                        },
                        "plans": [{
                                "networkId": "N1",
                                "tiering": [{
                                        "policyPlanID": "PP5"
                                    }
                                ]
                            }, {
                                "networkId": "N2",
                                "tiering": [{
                                        "policyPlanID": "PP1"
                                    }, {
                                        "policyPlanID": "PP5"
                                    }
                                ]
                            }
                        ]
                    }, {
                        "addressInfo": {
                            "city": "Pembroke Pines2",
                            "county": "Broward2",
                            "state": "FL2",
                            "zip": "330262"
                        },
                        "plans": [{
                                "networkId": "N2"
                            }

                        ]
                    }

                ]
            }
        ],
        "status": "OK"
    }

JSONPath表达式:$ ..分层[?(@。policyPlanID ==' PP1')])

匹配值

[
   {
      "policyPlanID" : "PP1"
   },
   {
      "policyPlanID" : "PP1"
   },
   {
      "policyPlanID" : "PP1"
   }
]

问题是有没有API来保护根级别的整个JSON结果的内容? 是否有任何特定的API来获取Paths的结果

[
   "$['results'][0]['locations'][0]['plans'][0]['tiering'][0]",
   "$['results'][0]['locations'][0]['plans'][2]['tiering'][0]",
   "$['results'][1]['locations'][0]['plans'][1]['tiering'][0]"
]

0 个答案:

没有答案