diff --git a/json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java b/json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java index 047a003..8c5373d 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java +++ b/json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java @@ -134,11 +134,19 @@ public void checkLeadinZero() throws ParseException { protected Number extractFloat() throws ParseException { if (!acceptLeadinZero) checkLeadinZero(); - if (!useHiPrecisionFloat) - return Float.parseFloat(xs); - if (xs.length() > 18) // follow JSonIJ parsing method - return new BigDecimal(xs); - return Double.parseDouble(xs); + + try { + if (!useHiPrecisionFloat) + return Float.parseFloat(xs); + + if (xs.length() > 18) // follow JSonIJ parsing method + return new BigDecimal(xs); + + return Double.parseDouble(xs); + + } catch(NumberFormatException e){ + throw new ParseException(pos, ERROR_UNEXPECTED_TOKEN, xs); + } } /**