jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Schumacher <>
Subject Re: Want to get Integer value only from rational number
Date Fri, 10 May 2019 12:24:27 GMT

Am 10.05.19 um 12:54 schrieb Shyam Panjiyar:
> Hi ,
> Could you please help with Bean Shell Sampler Script for below  requirement :-
> Input - String sequence from JSON Extractor as 123.0
> Output - String sequence in variable as 123

Last mail you asked about a conversion from JSON Extractor
123.0/124.0/125.0 to 123/124/125.

As it is almost the question about extracting multiple values from json
on stackoverflow
I will quote and enhance my answer here inline (Note that I used ',' as
the separator, as it is the default as I believe):

Assuming you have a JSON structure like this

|{"body":[{"count":0.0 },{"count":23.0 },{"count":-1.0 },{"count":20.0
},{"no_count_here":"really"}]} and your JSON Extractor uses
"countFromResponse" as "Names of created variables", "$.body[*].count"
as "JSON Path expression", "-1" for "Match No." and check "Compute
concatenation var". |

Then your Post Processor will add a variable named |"countFromResponse|"
with the content |"0.0,23.0,-1.0,20.0"|. To round these values, you have
to split the string at each comma, convert the string snippets to Double
values and round them. Then convert them back to strings and join those
again. That value can then be stored in another variable named

This can be accomplished using a JSR223 Post Processor, that uses the
following groovy code:

|overall =vars.get("countFromResponse_ALL").split(",").collect
{Math.round(Double.valueOf(it)).toString()} .join(",")

The conversion back to string is important, as all normal variables in
JMeter will be treated as strings.


> Thanks & Regards,
> Shyam Panjiyar
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message