JSONPath 表达式根据条件从数组中获取对象

问题描述 投票:0回答:1

给定 JSON 结构

{
  "total_institutions": 2,
  "count_by_institution": [
    {
      "institution": {
        "id": "03629",
        "name": "institutiona03629"
      },
      "total_branches": 5
    },
    {
      "institution": {
        "id": "03659",
        "name": "institutiona03659"
      },
      "total_branches": 3
    }
  ]
}

我是 JSon Path 的新手。我需要一个 JSONPath 表达式来获取名称等于institutiona03659 的机构对象。所以,根据上面的例子,结果应该是

{
  "institution": {
    "id": "03629",
    "name": "institutiona03629"
  },
  "total_branches": 5
}
json jmeter jsonpath
1个回答
0
投票

怎么样

$..[?(@.institution.name == 'institutiona03659')]

更多信息:

© www.soinside.com 2019 - 2024. All rights reserved.