Reputation: 89
I am trying to extract multiple values from a JSON response on my jmeter script. Below is sample of my response:
{ "startDate": "2018-12-10T15:36:34.400+0000", "userId": "7211111-2fa90", "createdBy": "TEST", "note": { "content": "Application Submitted " }, "Type": "SUBMITTED" },
"currentEventState": "CLOSED",
{
"Xxxx": "test",
"Loc": null,
"Zipcode": [],
"Locality": 82,
"Address": {
"Add": 12302,
"Add2": "place",
"Zip": {
"Phone": "home",
"Email": "[email protected]"
}
},
"state": "MD",
"Cost": "E "
},
"AppID": "cd8d98e6-c2a79",
"Status": "CLOSED",
}
I am trying to extract userid and AppID for the case if the TYPE is Submitted and Status is Closed.I tried using the Json extractor with $.[?(@.Type=="SUBMITTED")].[*].?(@.Status=="CLOSED").userid,APPID
, but couldn't get the expected result. Could anyone guide me on this.
Upvotes: 0
Views: 3614
Reputation: 168217
You need to use an inline predicate to combine 2 clausees and a semicolon in order to store results into 2 separate JMeter Variables.
Configure it as follows:
userid;appid
$..[?(@.Type=='SUBMITTED' && @.Status == 'CLOSED')].userId; $..[?(@.Type=='SUBMITTED' && @.Status == 'CLOSED')].AppID
NA;NA
Here is the demo of single expression working fine:
And here are extracted values reported by the Debug Sampler:
Upvotes: 1