Home/How to get value from Response and refer in Request using JSON Extractor in jmeter

How to get value from Response and refer in Request using JSON Extractor in jmeter

Published On: 6 June 2022.By .
  • General
  • Quality Engineering

JSON Extractor:-

JSON (JavaScript Object Notation) Extractor is used to extract the values from JSON response.When user need to extract the values from JSON response and pass into some other request in the JMeter script then we can use JSON Extractor. It is a post-processor.

How to add JSON Extractor

  1. Add a Thread group.
  2. Add http request and add JSON Extractor as a child of the request.

Add JSON Extractor

3.  Provide values in required fields as variable name,JSON path expressions etc.

JSON path expression/Variable-In the response the value of token assigned to “fesToken” so user have to just mention it in the JSON path expression with $ as $.data.fesToken and  whatever value assigned to this token will extract from there and assigned to variable name as BearerToken as given below-

JSON Extractor contains following fields:-

  • Variables Names: The name of the variables in which required JSON values will be stored. In the above example TokenValue is the name of variable.
  • JSON Path Expressions: expressions to extract content from the json response. In the above example $.data.fesToken is the path of json expression.
  • Match Numbers: ‘-1’ is used to capture all the values while ‘0’ is used to pick a random value.If more than 1 strings are matched in a response data and user want to use the JSON variable value which comes at a particular place (say 2nd place) then user  have to give 2 as an input and JMeter will recognize all the matched values on the page but store only 2nd value in the variable. 
  • Default values: This is the default value when extraction does not apply to the JSON document then this value will display there. In the above example TokenNotFound  is the default value.

4. Now add another http request and add that bearer token under authorization parameter,and user have to append “bearer” with the token as bearer ${variable Name}

Related content

We Love Conversations

Say Hello
Go to Top