Skip to content

Commit 56cb5f8

Browse files
committed
#653 - review comments updated.
1 parent 0cdc38a commit 56cb5f8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/org/json/JSONObject.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,17 +2416,16 @@ protected static Number stringToNumber(final String input) throws NumberFormatEx
24162416
try {
24172417
Double d = Double.valueOf(val);
24182418
if(d.isNaN() || d.isInfinite()) {
2419-
throw new NumberFormatException("val ["+val+"] is not a valid number.");
2419+
throw new NumberFormatException("val ["+input+"] is not a valid number.");
24202420
}
24212421
return d;
24222422
} catch (NumberFormatException ignore) {
2423-
throw new NumberFormatException("val ["+val+"] is not a valid number.");
2423+
throw new NumberFormatException("val ["+input+"] is not a valid number.");
24242424
}
24252425
}
24262426
}
24272427
val = removeLeadingZerosOfNumber(input);
24282428
initial = val.charAt(0);
2429-
// block items like 00 01 etc. Java number parsers treat these as Octal.
24302429
if(initial == '0' && val.length() > 1) {
24312430
char at1 = val.charAt(1);
24322431
if(at1 >= '0' && at1 <= '9') {
@@ -2934,10 +2933,12 @@ private static String removeLeadingZerosOfNumber(String value){
29342933
int counter = negativeFirstChar ? 1:0;
29352934
while (counter < value.length()){
29362935
if (value.charAt(counter) != '0'){
2937-
return String.format("%s%s", negativeFirstChar?'-':"",value.substring(counter));
2936+
if (negativeFirstChar) {return "-".concat(value.substring(counter));}
2937+
return value.substring(counter);
29382938
}
29392939
++counter;
29402940
}
2941-
return String.format("%s%s", negativeFirstChar?'-':"",'0');
2941+
if (negativeFirstChar) {return "-0";}
2942+
return "0";
29422943
}
29432944
}

0 commit comments

Comments
 (0)