]> source.dussan.org Git - poi.git/commitdiff
GenericRecordJsonWriter fix output of floats and doubles
authorAndreas Beeker <kiwiwings@apache.org>
Fri, 29 Nov 2019 00:29:05 +0000 (00:29 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Fri, 29 Nov 2019 00:29:05 +0000 (00:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1870565 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/util/GenericRecordJsonWriter.java

index 43e23f31ea0b4627f863051ea486cfeb6f17e947..f8a0c85a4e98275dbc3425144b031c656e95c646 100644 (file)
@@ -258,6 +258,15 @@ public class GenericRecordJsonWriter implements Closeable {
     protected boolean printNumber(String name, Object o) {
         Number n = (Number)o;
         printName(name);
+
+        if (o instanceof Float) {
+            fw.print(n.floatValue());
+            return true;
+        } else if (o instanceof Double) {
+            fw.print(n.doubleValue());
+            return true;
+        }
+
         fw.print(n.longValue());
 
         final int size;