0

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!

1
  • "1.251592097E7" (1.251.. * 10^7) is just a different writing for your value (12515920.97) so is this really an issue? Commented Jul 14, 2021 at 17:08

2 Answers 2

1

If you want to store the value "as is" the easiest option is going for the JSR223 Post-Processor and fetch your value using Groovy

Example code:

vars.put('your_variable_name_here', new groovy.json.JsonSlurper().parse(prev.getResponseData()).endValue.amount as String)

Demo:

enter image description here

More information:

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for always giving solutions for the JSR223 element in groovy.
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.