0
votes

I am getting an output like

Jmeter Request Response

Plain response:

ticket_tax_dtls_id  tax_code    tax_amount_remitted tax_amount_p‌​roposed   tax_amount_a‌​pplicable 
667894  CN 140.0    null    140.0 
667895  US  232.0   null    232.0 
667896  YC  36.0    null    36.0 
667904  BP  56.0    null    56.0 
667905  XA 26.0 null    26.0 
667906  XF  30.0    null    30.0 
667914  AY  37.0    null    37.0 
667915  XY  46.0    null    46.0 
667916 XFHNL4.5 0.0 null    0.0

in Jmeter. And I need to capture the dynamic file name using regular expression extractor and capture all the variables and pass it on further in a request as below.

[["key0",{"taxcode":"CN","remtAmt":"90.0","propAmt":"90.0","appAmt":"90.0","apcode":"","ticketTaxId":"677839"}],["key1",{"taxcode":"XA","remtAmt":"26.0","propAmt":"","appAmt":"26.0","apcode":"","ticketTaxId":"677840"}],["key2",{"taxcode":"XF","remtAmt":"90.0","propAmt":"","appAmt":"90.0","apcode":"","ticketTaxId":"677841"}],["key3",{"taxcode":"XFHNL4.5","remtAmt":"0.0","propAmt":"","appAmt":"0.0","apcode":"","ticketTaxId":"677842"}],["key4",{"taxcode":"AY","remtAmt":"74.0","propAmt":"","appAmt":"74.0","apcode":"","ticketTaxId":"677849"}],["key5",{"taxcode":"XY","remtAmt":"46.0","propAmt":"","appAmt":"46.0","apcode":"","ticketTaxId":"677850"}],["key6",{"taxcode":"XFHNL4.5","remtAmt":"0.0","propAmt":"","appAmt":"0.0","apcode":"","ticketTaxId":"677851"}],["key7",{"taxcode":"US","remtAmt":"293.0","propAmt":"","appAmt":"293.0","apcode":"","ticketTaxId":"677859"}],["key8",{"taxcode":"YC","remtAmt":"36.0","propAmt":"","appAmt":"36.0","apcode":"","ticketTaxId":"677860"}],["key9",{"taxcode":"XFLAS4.5","remtAmt":"0.0","propAmt":"","appAmt":"0.0","apcode":"","ticketTaxId":"677861"}]]

I have tried making an array for each parameter but failed.

ticket_tax_dtls_id\n(\d+)

DB output is like below.

DB Output

1
I observed that in JSON request, you are sending old tax id values as 677839, 677840 etc. but where the response contains 667894,667895etc. Are you replacing the JSON request tax id values with regex captured values?Naveen Kumar R B
Hi, This is the existing JSON request. I have not replaced with the variable coz I have not got one. Tried this ticket_tax_dtls_id(\n(\d+))+ for capturing ticket_tax_dtls_id @Naveenuser3627319
could you please post the response as plain text instead of image? so, we can try it outNaveen Kumar R B
ticket_tax_dtls_id tax_code tax_amount_remitted tax_amount_proposed tax_amount_applicable 667894 CN 140.0 null 140.0 667895 US 232.0 null 232.0 667896 YC 36.0 null 36.0 667904 BP 56.0 null 56.0 667905 XA 26.0 null 26.0 667906 XF 30.0 null 30.0 667914 AY 37.0 null 37.0 667915 XY 46.0 null 46.0 667916 XFHNL4.5 0.0 null 0.0 @Naveenuser3627319

1 Answers

0
votes

the following regex worked for me:

(\d{6})\s+\w+

Use the settings shown in the screenshot to capture multiple values.

Screenshot references:

Regex extractor:

enter image description here

View Results Tree:

enter image description here

Total 9 values are captured for the given sample output in the question.

We can access each one of them later (tax_id is reference name), as follows:

first match : ${tax_id_1}
second match : ${tax_id_2}
continues..