From 0769babcda4db6e15f2a0e2cb118275dc4aa24bf Mon Sep 17 00:00:00 2001 From: devjeonghwan Date: Tue, 28 Sep 2021 19:03:44 +0900 Subject: [PATCH] Fix floating data problem --- src/main/java/com/realtimetech/kson/KsonContext.java | 2 +- src/main/java/com/realtimetech/kson/test/TestObject.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/realtimetech/kson/KsonContext.java b/src/main/java/com/realtimetech/kson/KsonContext.java index 3d89f04..f1d7146 100644 --- a/src/main/java/com/realtimetech/kson/KsonContext.java +++ b/src/main/java/com/realtimetech/kson/KsonContext.java @@ -925,7 +925,7 @@ public JsonValue fromString(String kson) throws IOException { this.stringMaker.add(currentChar); } } else if (currentMode == ValueMode.NUMBER) { - if (!(currentChar >= '0' && currentChar <= '9') && currentChar != '-' && currentChar != 'D' && currentChar != 'd' && currentChar != 'F' && currentChar != 'f' && currentChar != 'L' && currentChar != 'l' && currentChar != 'B' && currentChar != 'b' && currentChar != '.') { + if (!(currentChar >= '0' && currentChar <= '9') && currentChar != 'E' && currentChar != 'e' && currentChar != '+' && currentChar != '-' && currentChar != 'D' && currentChar != 'd' && currentChar != 'F' && currentChar != 'f' && currentChar != 'L' && currentChar != 'l' && currentChar != 'B' && currentChar != 'b' && currentChar != '.') { modeStack.pop(); currentMode = modeStack.peek(); diff --git a/src/main/java/com/realtimetech/kson/test/TestObject.java b/src/main/java/com/realtimetech/kson/test/TestObject.java index f51bb1c..647855d 100644 --- a/src/main/java/com/realtimetech/kson/test/TestObject.java +++ b/src/main/java/com/realtimetech/kson/test/TestObject.java @@ -18,6 +18,8 @@ public class TestObject { private TestEnum enumType1; private TestEnum enumType2; + private double floating; + private String[] emptyArray; @Ignore @@ -196,6 +198,8 @@ public TestObject(Test test) { this.intArray = new int[] { 1, 2, 3, 4 }; this.integer = 1; + this.floating = 5.136898340781836E-5; + this.emptyArray = new String[0]; this.stringArray = new String[] { "A", "B", "C" }; this.string = "ABC";