Reputation: 181
can somebody help me how to create regex from this? I need only text after a_n: "
so I need only this text. e.g. jgoijODIJGojsklfj4dgdg_797gsdg-df_gsdfh-dhfGSDhfdsg-dfg
{
"a_n": "jgoijODIJGojsklfj4dgdg_797gsdg-df_gsdfh-dhfGSDhfdsg-dfg",
"type": "something",
"uuser": "userid",
"expire": "6018"
}
Upvotes: 0
Views: 84
Reputation: 168122
JMeter's Regular Expression Extractor uses Perl-5 style regular expressions so the relevant configuration would be:
"a_n": "(.+?)"
$1$
Also be aware that it makes more sense to use JSON Extractor to work with JSON responses. The relevant JSON Path query would be as simple as $.a_n
Demo:
More information: API Testing With JMeter and the JSON Extractor
Upvotes: 0
Reputation: 2978
To extract this in JMeter:
Add a jp@gc - JSON Path Extractor under your request sampler.
To extract the required data, you have to set like this:
Your extracted value will be saved in the variable Jsonvar
.
Now You can use this variable other subsequent requests.
Upvotes: 0
Reputation: 725
Please have a look (how to use a regular expression to extract json fields?)
regex should be,
/"a_n":\ ?"((\\"|[^"])*)"/i
Upvotes: 1
Reputation: 8380
You can achieve this with JSONStream.
cat file.json | JSONStream '.a_n'
And also with jq:
jq .a_n file.json
Upvotes: 1
Reputation: 2893
If you can, just use a JSON parser to get the value. Otherwise you can use
/{.*\"a_n\": \"(.*)\".*/
Upvotes: 1