Skip to content

Commit

Permalink
vert-x3#110 first try to parse the string as Integer
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Westermann committed Feb 5, 2020
1 parent ef08647 commit 761a7cc
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,16 @@ public static Object convert(String value) {
return bool;
}

Double integer = asNumber(value);
Integer integer = asInteger(value);
if (integer != null) {
return integer;
}

Double doubleValue = asNumber(value);
if (doubleValue != null) {
return doubleValue;
}

JsonObject obj = asJsonObject(value);
if (obj != null) {
return obj;
Expand All @@ -71,6 +76,14 @@ public static Object convert(String value) {
return value;
}

private static Integer asInteger(String s) {
try {
return Integer.parseInt(s);
} catch (NumberFormatException nfe) {
return null;
}
}

private static Double asNumber(String s) {
try {
return Double.parseDouble(s);
Expand Down

0 comments on commit 761a7cc

Please sign in to comment.