Exclude blank values from csv file for JSON array in Jmeter -


i have jsonarray [foodid1,foodid2,foodid3] .the values of these reading csv file

csv file content

foodid1,foodid2,foodid3 10,12,14 

if don't want pass value foodid2, json array being passed [10,,14]

instead, wanted passed [10,14].

following json body:

    customerdetails={     "regdate":${regdate},     "regno":"${regno}",     "firstname":"${fname}",     "lastname":"${lname}",     "dateofbirth":"${dob}",     "bloodgroupid":0,     "mobileno":"${mobile}",     "residenceno":"${resdno}",     "officeno":"${officeno}",     "email":"${email}",     "address1":"${adr1}",     "address2":"${adr2}",     "pincode":"${pin}",     "stateid":${stateid},     "city":"${city}"} &customerhistory={ "historyid":[${food1},${food2},${food3},${food4}]} 

how can handle situation in jmeter

thanks in advance

the easiest solution replacing double commas single commas on fly using beanshell preprocessor

  1. add beanshell preprocessor child of http request you're going modify
  2. put following code preprocessor's "script" area:

    import org.apache.jmeter.config.arguments; import org.apache.jmeter.config.argument; import org.apache.jmeter.protocol.http.util.httpargument;  arguments oldargs = sampler.getarguments(); arguments newargs = new arguments();  (int = 0; < oldargs.getargumentcount(); i++) {     argument argument = oldargs.getargument(i);     string oldvalue = argument.getvalue();     string newvalue = oldvalue.replaceall(",,", ",");     newargs.addargument(new httpargument(argument.getname(), newvalue)); }  sampler.setarguments(newargs); 

    when run test preprocessor replace ,, , each parameter value.

see how use beanshell: jmeter's favorite built-in component article more information using beanshell in jmeter tests.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -