嵌套数组的jayway json路径

时间:2019-10-16 21:34:40

标签: java json jayway

我有以下json,并且当类型名称为“ route”时,我需要获取cntry = India

$.api.address_components.*.types[?(@.name=='route')]["cntry","name"]
{
  "api": {
    "address_components": [
      {
        "cntry": "India",
        "short_name": "Yonge St",
        "types": [
          {
            "name": "route"
          }
        ]
      },
      {
        "long_name": "USA",
        "short_name": "Willowdale",
        "types": [
          {
            "name": "Willowdale",
            "name3": "political"
          }
        ]
      }
    ],
    "status": "OK"
  }
}

尝试使用时无法提取

$.api.address_components.*.types[?(@.name=='route')]["cntry","name"]

获取名称而不是国家/地区。

预先感谢

0 个答案:

没有答案