Monday, November 3, 2025

efficiency – Learn how to parse Json information which is within the HTTP put up request in JMeter – Software program High quality Assurance & Testing Stack Change


Since request payloads should be composed by your self, it does not make a lot sense to extract information from there.
Is smart, as an alternative, to fill them with information you are taking/populate from someplace.

What might simply be finished then, is to populate the request physique with variables, so your request physique might appear to be this:

{  
   "key phrase":"${Key phrase}",
   "maxlength":25,
   "offset":0,
   "sortKeys":{  
      "ascending":false,
      "attributeName":"relevance",
      "kind":"ATTRIBUTE"
   },
   "filterKeys":{  
      "${filter_key}":[  
         "${filter_value}"
      ]
   },
   "lastFilterGroup":"${filter_key}"
}

And add a JSR223 PreProcessor (utilizing groovy) to that request sampler, the place to place values for these variables, like:

vars.put('filter_key', 'analyte');
vars.put('filter_value', 'Phenols');

In any other case, if you wish to extract “analyte” and “Phenol” from that JSON physique, given it’s a response, you possibly can add a JSON Extractor to the sampler and use the next path expressions

$.filterKeys

to get

[
  {
    "analyte": [
      "Phenols"
    ]
  }
]

and

$.filterKeys.analyte.*
// or
$.filterKeys.${filter_key}.*

to get

[
  "Phenols"
]

or different combos which you could check out on a number of web sites like this.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

PHP Code Snippets Powered By : XYZScripts.com