Tuesday, January 9, 2018

Using JSON extractor in Jmeter: How to deal with dynamic values in JSON response

How To use JSON Extractor in Jmeter

Json extractor is used like regular expression extractor to capture some dynamic values from the response but used for json only.

By using this we can fetch the values of variables in the Json.

Let me take an example

Below is the Json and its corresponding response:


Here we want to extract the value of variable name "label" or "val"
 which are changing dynamically

We can use Json extractor to fulfil thie purpose here

below is the JSON values that can be used



In this Json extractor blow are the parameters and their corresponding values

Variable Name: Name of the variable (can be used anything logical, here we have used the same as we are getting in response)

JSON Path expression: It is the most important part for JSON configurations, We should use the path extractor expression here.
 Here we have used $..lable , Here two dot means we have json variable in two nested blocks, For normal JSON where there is only one tag , we used single dot.

Match Number: 0 means any random value, here we can use 1 or 2 to get first value or second value and so on, we can also use -1 for getting all possible values to be stored in array (with variable name as mentioned above)

Default Values: this values that can be passed when we didnt got the expected value.


TO varify the value captured in Json extractor:

We can use the Debug Sampler on the thread group to validate the value captured using Json extarctor, Debug sample is used to print all the used defined configured variable in jmeter.


Here we can see that variable "label": captured SpiceJet , and lable_matchNr having value as 10 because there are 10 occurrence of the values corresponding to the expression we have defined for variable label in JSON extractor.


Feel Free to add if i have missed anything.



6 comments:

  1. This is fundamentally the same as the old showcasing procedure of getting somebody on your mailing list. best email spider

    ReplyDelete
  2. Public statements are frequently sent to the forthcoming clients through emails. Bulk Email Sender

    ReplyDelete
  3. This content is written very well. Your use of formatting when making your points makes your observations very clear and easy to understand. Thank you. targeted email extractor

    ReplyDelete
  4. Fire Damage Restoration Services in Sacramento CA systems that keep our home comfortable all year long. Maintenance plays a key role in ensuring that our cooling system stays running smoothly and save our investment.

    ReplyDelete

plz give ur comments !!!!!!