how to extract json response data in jmeter using regular expression extractor?

16,502

Is authorizationToken appearance unique in response (does it appear only once)?

If it does you may simply use Regular Expression Extractor added to the HTTP Request which returns json response, with regex like following:

HTTP Request
    Regular Expression Extractor
    Reference Name: authToken
    Regular Expression: "authorizationToken":"(.+?)"
    Template: $1$
    Match No.: 1

and refer further extracted value as ${authToken}.


But if your case is more complicated and there several appearances of authorizationToken in json response and you have to extract concrete one you may use e.g. BeanShell PostProcessor / BSF PostProcessor added to the same HTTP Request to extract value with beanshell code + json processing library.

If not - the first solution above should help.


UPDATE:

At the moment the most comfortable way to process JSON responses seems to be custom JSON utils for jmeter (JSON Path Assertion, JSON Path Extractor, JSON Formatter) which are also part of Jmeter Plugins.

In this particular case you can use JSON Path Extractor.

Share:
16,502
Hitendra
Author by

Hitendra

Senior Android Developer at Reputed Web Application Development Company based NJ USA

Updated on June 11, 2022

Comments

  • Hitendra
    Hitendra almost 2 years

    I am just trying to extract json response data using jmeter but not able to do so.
    I am getting something like {"authorizationToken":"abcdef"}.
    I am trying to get authorizationToken but not able to get this.

    Can anyone help me getting this working?

  • Hitendra
    Hitendra about 12 years
    Thanks Alies.Actually i have defined the same variable "AUTHTOKEN" in user defined variables.That was causing error.I have removed it and it just works fine.