Search code examples
arraysjsonjmeterresponsejmespath

Jmeter JMESPath extraction with Partial text or contains filter


Hello can someone help me simulate this scenario. Because I want to use contains or Partial text on my filter using JMESPath extractor on Jmeter.

Sample Response:

[{ "orgName": "MNL_Automation", "name": "Test-123", "agentMap": { "25b08b79-d2e6-3313-bf39-8d1a8bf318d5": "DATABASE", "9af282a5-1d13-3050-8912-ab29275f215d": "BUSHIDO APPLIANCE", "4013a43f-0ea2-3df0-8fc3-9e562a7f82c7": "APACHE TOMCAT", "a51df66c-7b0d-30b8-85db-03605246aecf": "AD SERVER" } }, { "orgName": "MNL_Automation", "name": "Test-132", "agentMap": { "25b08b79-d2e6-3313-bf39-8d1a8bf318d5": "DATABASE2", "9af282a5-1d13-3050-8912-ab29275f215d": "Testing APPLIANCE", "4013a43f-0ea2-3df0-8fc3-9e562a7f82c7": "APACHE TOMCAT", "a51df66c-7b0d-30b8-85db-03605246aecf": "AD UAT" } }, { "orgName": "DEPARTMENT 2", "name": "BUSHIDO", "teams": "{"APPLICATION_ADMIN":"30084152-5ddc-3079-a765-dbbcd58f2391"}", "agentMap": { "c1716dcd-5181-3e9e-ac05-0e0cc48b0789": "AD SERVER" } } ]

Response Screenshot:

enter image description here

Expected Result: Will Extract all agentMap values with the name starts with Test

enter image description here

Currently I'm just using exact filter but it returns me single filter and I want to use Partial text/Contains to make my the script more flexible. Your response is highly appreciated. Thank you so much

enter image description here


Solution

  • Not sure whether it's possible to achieve with JSON JMESPath Extractor as JMeter's implementation doesn't strictly follow the JMESPath specification, however it should be possible to get it with JSON Extractor, the relevant JsonPath query would be something like:

    $..[?(@.name =~ /Test.*/)]
    

    Demo:

    enter image description here

    More information: JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios