杰克逊似乎在我试图序列化为 JSON 的任何数据结构中将所有浮点数强制转换为双精度数。有什么办法可以避免这种行为?
Float f = 50.1f;
System.out.println(f); // 50.1
System.out.println(f.doubleValue()); // 50.099998474121094
System.out.println(new ObjectMapper().valueToTree(f)); // 50.099998474121094 -- how to prevent this?
使用 jackson-all-1.9.11.jar。