How to read jmeter response data that comes as a CSV using the JSR223 PostProcessor and assign it to a JSON object

315 views Asked by At

I have an HTTP request that reads a csv file stored in a server. The response for that request comes as

login_type,username,password
data,data,data
data,data,data

(The file contains more than 1000 rows) Is there a way to read these individual data and pass on to three variables as i am required to pass these data rows on to the next request as {"login_type":"${login_type}","username":"${username}","password":"${password}"}

Using JSR223 PostProcessor i was able to read the response. The groovy script is below.

def res = prev.getResponseDataAsString()
log.info(res)

how can i parse these values into a json object and assign the values to the next request?

1

There are 1 answers

1
Dmitri T On

The easiest would be:

  1. Executing the request which retrieves this file somewhere in setUp Thread group
  2. Save it into a CSV file using Save responses to a file listener
  3. In the main Thread Group use CSV Data Set Config to read the values