1

下面是我试图提取匹配过滤器内容的 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 表达式:$..tiering[?(@.policyPlanID == 'PP1')])

匹配值是

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

问题是否有任何 API 可以从根级别保留整个 JSON 结果的内容?是否有任何特定的 API 来获取路径的结果

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

0 回答 0