Reputation: 167
From json
token_id="token_id":"82903430-f9b3-4f4b-9efa-ee1b991cb735"
I am extracting token_id
using jsonpath extractor $..token_id
.
And then using the variable in next post request, but it's showing extra brackets in call
"token_id":["82903430-f9b3-4f4b-9efa-ee1b991cb735"]
Upvotes: 4
Views: 5234
Reputation: 1
Use getToken_1
as suggested by Dmitri T to remove extra brackets, because in jmeterregex uses array to store the regexresponse.
${getToken_1}
is the proper Regex to remove the []
brackets from above response.
Upvotes: 0
Reputation: 168157
I belive that it is caused by changes introduced in jmeterPlugins version 1.3.0 where JSONPath
extractor support of returning multiple matching values was introduced.
You can work it around using one of 3 below approaches:
You can change your JSONPath
Expression to
$..token_id[0]
So you won't have to remove brackets and quotation marks manually
I believe you have something like:
getToken=["82903430-f9b3-4f4b-9efa-ee1b991cb735"]
getToken_1=82903430-f9b3-4f4b-9efa-ee1b991cb735
getToken_matchNr=1
So just using ${getToken_1}
should work like a charm
You can use Beanshell PostProcessor to remove brackets and quotation marks. Add it after the JSONPath
Extractor and put the following code into "Script"
area:
String getToken = vars.get("getToken");
getToken = getToken.replaceAll("\\[\"(.*?)\"\\]", "$1");
vars.put("getToken",getToken);
Upvotes: 6
Reputation: 5571
In JSON, brackets means array of strings, numbers, booleans, objects and arrays.
"token_id" is interpreted like a string array. Example:
"token_id":["82903430-f9b3-4f4b-9efa-ee1b991cb735"]
Make sure to change "token_id" to string.
Upvotes: 0