Skip to content

Commit 5504116

Browse files
authored
Merge pull request #61 from GanbaruTobi/master
Possible fix for Exception handling
2 parents ba7be16 + c98873a commit 5504116

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
@@ -139,11 +139,19 @@ public void checkLeadinZero() throws ParseException {
139139
protected Number extractFloat() throws ParseException {
140140
if (!acceptLeadinZero)
141141
checkLeadinZero();
142-
if (!useHiPrecisionFloat)
143-
return Float.parseFloat(xs);
144-
if (xs.length() > 18) // follow JSonIJ parsing method
145-
return new BigDecimal(xs);
146-
return Double.parseDouble(xs);
142+
143+
try {
144+
if (!useHiPrecisionFloat)
145+
return Float.parseFloat(xs);
146+
147+
if (xs.length() > 18) // follow JSonIJ parsing method
148+
return new BigDecimal(xs);
149+
150+
return Double.parseDouble(xs);
151+
152+
} catch(NumberFormatException e){
153+
throw new ParseException(pos, ERROR_UNEXPECTED_TOKEN, xs);
154+
}
147155
}
148156

149157
/**

0 commit comments

Comments
 (0)