0
votes

I am using JMeter and I want to extract a particular value from a JSON response and use this value in subsequent request. I have the JSON Extractor Plugin installed but I am able to drill down to the JSON value.

Below is an example JSON response captured from JMeter.

while(1);
{
:   "results":
:   [
:   :   {
:   :   :   "permissions":
:   :   :   [
:   :   :   ],
:   :   :   "exchangeId":"5wFrZHS8Obbw_JJOsaxy7A",
:   :   :   "documentIncomplete":false,
:   :   :   "dateCreated":1453718307090,
:   :   :   "finalized":false,
:   :   :   "voided":false,
:   :   :   "certified":false,
:   :   :   "dateModified":1453718307090,
:   :   :   "metaData":
:   :   :   [
:   :   :   ],
:   :   :   "documentCreated":false,
:   :   :   "orphaned":false,
:   :   :   "dynamicName":false,
:   :   :   "description":"",
:   :   :   "mode":"ADHOC",
:   :   :   "state":"WITHOUT_DOCUMENT",
:   :   :   "name":"01/25/2016 10:38:21",
:   :   :   "priority":"C"
:   :   }
:   ],
:   "responseTime":1453718307090
}

I've tried the below but still can't get the exchangeId:

$.permissions[2].exchangeId

$.while..exchangeId

$.permissions.exchangeId

$.results.permissions.exchangeId

$.while.results.permissions.exchangeId

$.while.results[*].permissions.exchangeId

$.while.results[1].permissions[0].exchangeId

Am I doing something wrong here? Any help here is appreciated, I tried searching and couldn't find anything that relates to my problem.

1

1 Answers

0
votes

This is not a valid JSON, go for Regular Expression Extractor instead, the relevant configuration would be:

  • Reference Name: anything meaningful, i.e. exchangeId
  • Regular Expression: "exchangeId":"(.+?)"
  • Template: $1$

You will be able to access extracted value as ${exchangeId} where required.

Demo:

Regular Expression Extractor Demo

References: