jsonjmeterextractor

Jmeter - JSON Extractor - Large numbers erroring


Hope someone can help me :)
I have the response json below :

"endValue":{"amount":12515920.97,"currencyCode":"EUR"}

and I'm using the JSON extractor to retrieve the "amount" number and is working fine for any numbers that have up till 6 characters before the decimal point, but for large numbers like this one, is actually saving "1.251592097E7" on my variable. Is this a limitation or is there any other way that I can have the full number extracted?
Thanks in advance!


Solution

  • All the digits of the number are there, it is just that it is being displayed in scientific notation.

    You can format the number when the program needs to display it, for example using DecimalFormat:

    import java.text.DecimalFormat;
    
    public class Example{
    
         public static void main(String []args){
            double x = 12515920.97;
            DecimalFormat df = new DecimalFormat("#,###,###,##0.00");
            String result = df.format(x);
            System.out.println(result);
         }
    }
    

    Outputs:

    12,515,920.97