Precision loss in JSON to ION conversion for numeric values containing exponents

319 Views Asked by At

As per ION Cookbook, these are rules for converting numeric values in JSON to ION:

1. Numeric values without a decimal point are interpreted as Ion integers
2. Numeric values with a decimal point but without an exponent are interpreted as Ion decimals
3. Numeric values with exponents are interpreted as Ion floats

Why numeric values with exponents are converted to float? Is there some specification that is being followed?

I am converting JSON record containing exponent to ION record. How can I preserve the precision in this case? I am using Ion Java library.

String payload = "{\"abc\":\"aa\",\"xyz\":1232323232320003434234222222222223333333333333333311111112321234e-49}";
final IonValue value = ION.singleValue(payload);
System.out.println(value); // {abc:"aa",xyz:1.2323232323200034E14}
0

There are 0 best solutions below