Need a json path expression for below json

2019-08-18 08:06发布

Need a JSON path expression for below JSON. I wanted to extract "Id" for each specific "name"

For Example: I need to extract "Id" : "3" for "name" : "XYZ" .

I tried a JSON path expression as $..Id which given output as:

[
   "1",
   "2",
   "3"
]

But I needed an Id specific to "name": "XYZ"`

[
   {
      "primary":{
         "name":"ABC"
      },
      "Id":"1"
   },
   {
      "primary":{
         "name":"PQR"
      },
      "Id":"2"
   },
   {
      "primary":{
         "name":"XYZ"
      },
      "Id":"3"
   }
]

1条回答
等我变得足够好
2楼-- · 2019-08-18 08:35

Able to resolve this by below expression

$..[?(@.primary.name == 'XYZ')].Id
查看更多
登录 后发表回答