You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/11/17 13:44:54 UTC

svn commit: r1036009 - in /pivot/branches/1.5.x/core: src/org/apache/pivot/json/JSONSerializer.java test/org/apache/pivot/json/test/JSONSerializerTest.java

Author: gbrown
Date: Wed Nov 17 12:44:53 2010
New Revision: 1036009

URL: http://svn.apache.org/viewvc?rev=1036009&view=rev
Log:
Support negative floating point exponent values in JSONSerializer.

Modified:
    pivot/branches/1.5.x/core/src/org/apache/pivot/json/JSONSerializer.java
    pivot/branches/1.5.x/core/test/org/apache/pivot/json/test/JSONSerializerTest.java

Modified: pivot/branches/1.5.x/core/src/org/apache/pivot/json/JSONSerializer.java
URL: http://svn.apache.org/viewvc/pivot/branches/1.5.x/core/src/org/apache/pivot/json/JSONSerializer.java?rev=1036009&r1=1036008&r2=1036009&view=diff
==============================================================================
--- pivot/branches/1.5.x/core/src/org/apache/pivot/json/JSONSerializer.java (original)
+++ pivot/branches/1.5.x/core/src/org/apache/pivot/json/JSONSerializer.java Wed Nov 17 12:44:53 2010
@@ -382,7 +382,7 @@ public class JSONSerializer implements S
         }
 
         while (c != -1 && (Character.isDigit(c) || c == '.'
-            || c == 'e' || c == 'E')) {
+            || c == 'e' || c == 'E' || c == '-')) {
             stringBuilder.append((char)c);
             integer &= !(c == '.');
             c = reader.read();

Modified: pivot/branches/1.5.x/core/test/org/apache/pivot/json/test/JSONSerializerTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/1.5.x/core/test/org/apache/pivot/json/test/JSONSerializerTest.java?rev=1036009&r1=1036008&r2=1036009&view=diff
==============================================================================
--- pivot/branches/1.5.x/core/test/org/apache/pivot/json/test/JSONSerializerTest.java (original)
+++ pivot/branches/1.5.x/core/test/org/apache/pivot/json/test/JSONSerializerTest.java Wed Nov 17 12:44:53 2010
@@ -52,6 +52,12 @@ public class JSONSerializerTest {
     }
 
     @Test
+    public void testE() throws SerializationException {
+        assertEquals(5000000, JSONSerializer.parseDouble("5.0E6"), 0);
+        assertEquals(0.000005, JSONSerializer.parseDouble("5.0E-6"), 0);
+    }
+
+    @Test
     public void testEquals() throws IOException, SerializationException {
         JSONSerializer jsonSerializer = new JSONSerializer();
         Object o1 = jsonSerializer.readObject(getClass().getResourceAsStream("sample.json"));