1

根据ION Cookbook,这些是将 JSON 中的数值转换为 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

为什么带指数的数值被转换为浮点数?是否有一些正在遵循的规范?

我正在将包含指数的 JSON 记录转换为 ION 记录。在这种情况下如何保持精度?我正在使用Ion Java库。

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

0 回答 0