Search code examples
arraysjsonapijmeterresponse

Jmeter JSON response converting to an Array with request modification


Hello I want to simulate this scenario , example if I got this response below, I want to use that on my succeeding request. The appid will be use for key and Role to value parameter. Your response is highly appreciated. Thank you so much.

Request:

[{
    "appid": "4a157c66-4965-30b2-af47-7dc68651c350",
    "orgId": "205d64ff-9b58-3aad-bf48-29ec41dd4ef0",
    "ipAddress": "192.168.100.235",
    "Role" : "AD SERVER"}, 
{
    "appid": "ba3fe4b4-1307-38e4-ace4-1636f8ffef3e",
    "orgId": "205d64ff-9b58-3aad-bf48-29ec41dd4ef0",
    "ipAddress": "192.168.100.236",
    "Role" : "TESTING SERVER"
}, {
    "appid": "29b59fbb-ea93-3adf-ba9a-fd353abaac21",
    "orgId": "205d64ff-9b58-3aad-bf48-29ec41dd4ef0",
    "ipAddress": "192.168.100.237",
    "Role": "UAT SERVER"
}]

Response Screenshot:

enter image description here

Expected Result:

enter image description here


Solution

  • You could use JSON JMSEPath extractor to extract values and transform the keys. JMESPath Tutorial

    [].{Key:Role,Value:orgId}
    

    enter image description here

    Following demonstrate the testing the JSON JMESPath Query in the View Results Tree.

    enter image description here