Skip to content

Commit d832613

Browse files
committed
Fix parsing of double exponents in JSON (classgraph#353)
1 parent e538c44 commit d832613

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/main/java/nonapi/io/github/classgraph/json/JSONParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ private Number parseNumber() throws ParseException {
248248
throw new ParseException(this, "Expected digits after decimal point");
249249
}
250250
}
251-
final boolean hasExponentPart = peek() == '.';
251+
final boolean hasExponentPart = peek() == 'e' || peek() == 'E';
252252
if (hasExponentPart) {
253253
next();
254254
final char sign = peek();

src/test/java/nonapi/io/github/classgraph/json/JSONParserTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
package nonapi.io.github.classgraph.json;
22

3-
import nonapi.io.github.classgraph.types.ParseException;
43
import org.junit.Test;
54

6-
import java.lang.reflect.Constructor;
7-
import java.lang.reflect.Method;
8-
9-
import static org.junit.Assert.*;
5+
import nonapi.io.github.classgraph.types.ParseException;
106

7+
/**
8+
* Unit test.
9+
*/
1110
public class JSONParserTest {
11+
/** Test double value. */
1212
@Test
1313
public void test1() throws ParseException {
1414
JSONParser.parseJSON("{\"doubleValue\":-2.147483648}");
1515
}
1616

17+
/** Test double value with exponent. */
1718
@Test
1819
public void test2() throws ParseException {
1920
JSONParser.parseJSON("{\"doubleValue\":-2.147483648E9}");

0 commit comments

Comments
 (0)