通过Jmeter JSON响应迭代

时间:2017-12-27 09:23:56

标签: json jmeter

我正在使用 Jmeter 并获得以下回复

[
 {
"paxJourneyID": 9431,
"name": "KIRK JAMES MR",
"gender": "M",
"flight": {
  "carrier": "ABC",
  "fltNum": "0219",
  "depDate": "2017-12-29T00:00:00",
  "board": "DXB",
  "off": "BAH"
},
"seqNum": 0,
"pnrNum": "5D293N",
"tktNum": "1412100000150",
"priority": {
  "code": "",
  "entitledClass": ""
},
"groupCode": "",
"poolID": 0,
"poolHeadID": 0,
"isPrimaryPax": true,
"parentID": 0,
"totBagPieces": 0,
"totBagWeight": 0,
"outbound": [],
"class": "Y",
"paxStatusID": 0,
"appStatusID": 1,
"primaryDoc": {
  "docTypeID": 1,
  "docNum": "B76576557"
}
},
{
 "paxJourneyID": 12356,
 "name": "GREER JOAN MSTR",
 "gender": "M",
 "flight": {
  "carrier": "ABC",
  "fltNum": "0329",
  "depDate": "2017-12-29T00:00:00",
  "board": "DXB",
  "off": "BAH"
},
"seqNum": 0,
"pnrNum": "4WMAIT",
"tktNum": "",
"priority": {
  "code": "",
  "entitledClass": ""
 },
 "groupCode": "",
 "poolID": 0,
 "poolHeadID": 0,
 "isPrimaryPax": false,
 "parentID": 123,
 "totBagPieces": 0,
 "totBagWeight": 0,
 "outbound": [],
 "class": "Y",
"paxStatusID": 0,
"appStatusID": 2,
"primaryDoc": {
  "docTypeID": 1,
  "docNum": "767"
 }
}
]

我必须选择parentid为0的响应部分,在下一个请求中使用它。怎么做?

1 个答案:

答案 0 :(得分:1)

您可以使用JSON Extractor和以下JSONPath查询:

$..[?(@.parentID == 0)]

演示:

JMeter JSONPath Conditional

更多信息:JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios