mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-08 03:24:27 +08:00
#653 - review comments updated.
This commit is contained in:
@@ -2416,17 +2416,16 @@ public class JSONObject {
|
|||||||
try {
|
try {
|
||||||
Double d = Double.valueOf(val);
|
Double d = Double.valueOf(val);
|
||||||
if(d.isNaN() || d.isInfinite()) {
|
if(d.isNaN() || d.isInfinite()) {
|
||||||
throw new NumberFormatException("val ["+val+"] is not a valid number.");
|
throw new NumberFormatException("val ["+input+"] is not a valid number.");
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
} catch (NumberFormatException ignore) {
|
} catch (NumberFormatException ignore) {
|
||||||
throw new NumberFormatException("val ["+val+"] is not a valid number.");
|
throw new NumberFormatException("val ["+input+"] is not a valid number.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val = removeLeadingZerosOfNumber(input);
|
val = removeLeadingZerosOfNumber(input);
|
||||||
initial = val.charAt(0);
|
initial = val.charAt(0);
|
||||||
// block items like 00 01 etc. Java number parsers treat these as Octal.
|
|
||||||
if(initial == '0' && val.length() > 1) {
|
if(initial == '0' && val.length() > 1) {
|
||||||
char at1 = val.charAt(1);
|
char at1 = val.charAt(1);
|
||||||
if(at1 >= '0' && at1 <= '9') {
|
if(at1 >= '0' && at1 <= '9') {
|
||||||
@@ -2934,10 +2933,12 @@ public class JSONObject {
|
|||||||
int counter = negativeFirstChar ? 1:0;
|
int counter = negativeFirstChar ? 1:0;
|
||||||
while (counter < value.length()){
|
while (counter < value.length()){
|
||||||
if (value.charAt(counter) != '0'){
|
if (value.charAt(counter) != '0'){
|
||||||
return String.format("%s%s", negativeFirstChar?'-':"",value.substring(counter));
|
if (negativeFirstChar) {return "-".concat(value.substring(counter));}
|
||||||
|
return value.substring(counter);
|
||||||
}
|
}
|
||||||
++counter;
|
++counter;
|
||||||
}
|
}
|
||||||
return String.format("%s%s", negativeFirstChar?'-':"",'0');
|
if (negativeFirstChar) {return "-0";}
|
||||||
|
return "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user