how to get a string with double quotes and split it in jmeter

1.7k views Asked by At

I have the following string that is being returned from a regex extractor in a HTTP request.

issuerLogo2=,"issuerText":"humanaillinoishmo","networkType":"HMO","networkKey":"58288-ILN002","planScore":0.0,"rawOutOfPocketCost":0.0,"outOfPocketEstimate":0.0,"premiumBeforeCredit":231.29,"annualPremiumBeforeCredit":2775.48,"aptc":0.0,"totalContribution":0.0,"premiumAfterCredit":231.29,"annualPremiumAfterCredit":2775.48,"costSharingReductions":0.0,"adjustedOop":0.0,"oopMax":6300.0,"childOopMax":null,"maxTotalHealthCareCost":0.0,"estimatedTotalHealthCareCost":5075.48,"costSharing":null,"deductible":6100,"intgMediDrugDeductible":null,"medicalDeductible":4600,"drugDeductible":1500,

I would like to use the split this string to get values of all the attributes such as issuerText , networkType etc.

I am using beanshell sampler like

 vars line = vars.get(${issuerLogo2});
 String line = vars.get(${issuerLogo2});
 String line = vars.get("${issuerLogo2}"); 

etc.. i am getting error saying encountered '' Encountered "( ," or '' Encountered "\issuer\" ..

How do I escape the double quotes in the above string and get the issuerLogo2 value to a variable or another string in beanshell to split the string to get values of each attribute???

can someone pls help me on this ?

1

There are 1 answers

1
Dmitri T On

The correct Beanshell statement will look like:

String line = vars.get("issuerLogo2");

vars stands for JMeterVariables class instance hence vars.get() method expects variable name, and you're trying to pass variable value to it.

See How to use BeanShell: JMeter's favorite built-in component guide for more information on Beanshell scripting in JMeter.