Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support negative floating point exponent values in JSONSerializer.

git-svn-id: https://svn.apache.org/repos/asf/pivot/branches/1.5.x@1036009 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit d9a21718f182d3c667b18b0f2c62f6ec1cd0e6dd 1 parent 6c5deca
Gregory K. Brown authored
View
2  core/src/org/apache/pivot/json/JSONSerializer.java
@@ -382,7 +382,7 @@ private Object readNumber(Reader reader, Type type)
}
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();
View
6 core/test/org/apache/pivot/json/test/JSONSerializerTest.java
@@ -52,6 +52,12 @@ public void testInvalidNumbers() {
}
@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"));
Please sign in to comment.
Something went wrong with that request. Please try again.