Json 路径 - 如何仅从带有 "requests" 并给定 "title":"subject_2" 参数的部分获取 "id"?

Json path - how to get "id" only from the part with "requests" and given "title":"subject_2" parameter?

我有回复:

{"myRequests":[],

“请求”:[

{"id":"4919fe948-f4bb-4863","profileId":1,"comments":"","title":"subject_1" ...(bla-bla- bla)...,"名称":"Perf_1"},

{"id":"7295814a1-d1e7-440d","profileId":1,"comments":"","title":"subject_2" ...(bla-bla-bla)...,"name":"Perf_1"},

{"id":"0b548e6c2-ec40-4875","profileId":1,"comments":"","title":"subject_1" ...(bla-bla- bla)...,"名称":"Perf_1"},

{"id":"39c603faf-e3f7-4666","profileId":1,"comments":"","title":"subject_2" ...(bla-bla-bla)...,"name":"Perf_1"},

“批准的请求”:[

{"id":"83b8f6a65-da90-4b98","评论":"accept_1", ...(bla-bla-bla)...,"name":" =55=]"},

{"id":"4db544fd1-60fe-4b72","评论":"accept_1", ...(bla-bla-bla)...,"name":" =55=]"},

{"id":"24705ef9f-7c5c-4d43","评论":"accept_1", ...(bla-bla-bla)...,"name":" =55=]"},

{"id":"9d5238283-3da9-4d7d","评论":"accept_1", ...(bla-bla-bla)...,"name":" =55=]"}, ]}


我尝试使用

$.requests[?(@.comments=="")].id[0]

$.requests[?(@.comments=="" && @.title=="subject_2")].id[0]

但看不到效果 - 我缺少什么?

在这种情况下,正确的 json 路径应该是什么,只有来自带有“requests”和给定“title”的部分的“id”:“subject_2”参数?

我认为 JSON JMESPath Extractor and slightly amend your query to use pipe operator 这样会更容易:

requests[? comments==''].id | [0]

演示:

更多信息:The JMeter JSON JMESPath Extractor and Assertion: A Guide