Skip to content

Commit d07cf9f

Browse files
authored
Merge pull request #8 from GanbaruTobi/master
Uncaught Exception in Parser - Fix
2 parents a052934 + 3db4106 commit d07cf9f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,19 @@ public void checkLeadinZero() throws ParseException {
134134
protected Number extractFloat() throws ParseException {
135135
if (!acceptLeadinZero)
136136
checkLeadinZero();
137-
if (!useHiPrecisionFloat)
138-
return Float.parseFloat(xs);
139-
if (xs.length() > 18) // follow JSonIJ parsing method
140-
return new BigDecimal(xs);
141-
return Double.parseDouble(xs);
137+
138+
try {
139+
if (!useHiPrecisionFloat)
140+
return Float.parseFloat(xs);
141+
142+
if (xs.length() > 18) // follow JSonIJ parsing method
143+
return new BigDecimal(xs);
144+
145+
return Double.parseDouble(xs);
146+
147+
} catch(NumberFormatException e){
148+
throw new ParseException(pos, ERROR_UNEXPECTED_TOKEN, xs);
149+
}
142150
}
143151

144152
/**

0 commit comments

Comments
 (0)