Commit f2d3f51f authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '1.5.x'

parents c7f5f073 4568f14c
......@@ -30,11 +30,13 @@ class JSON {
static Boolean toBoolean(Object value) {
if (value instanceof Boolean) {
return (Boolean) value;
} else if (value instanceof String) {
}
else if (value instanceof String) {
String stringValue = (String) value;
if ("true".equalsIgnoreCase(stringValue)) {
return true;
} else if ("false".equalsIgnoreCase(stringValue)) {
}
else if ("false".equalsIgnoreCase(stringValue)) {
return false;
}
}
......@@ -44,12 +46,15 @@ class JSON {
static Double toDouble(Object value) {
if (value instanceof Double) {
return (Double) value;
} else if (value instanceof Number) {
}
else if (value instanceof Number) {
return ((Number) value).doubleValue();
} else if (value instanceof String) {
}
else if (value instanceof String) {
try {
return Double.valueOf((String) value);
} catch (NumberFormatException ignored) {
}
catch (NumberFormatException ignored) {
}
}
return null;
......@@ -58,12 +63,15 @@ class JSON {
static Integer toInteger(Object value) {
if (value instanceof Integer) {
return (Integer) value;
} else if (value instanceof Number) {
}
else if (value instanceof Number) {
return ((Number) value).intValue();
} else if (value instanceof String) {
}
else if (value instanceof String) {
try {
return (int) Double.parseDouble((String) value);
} catch (NumberFormatException ignored) {
}
catch (NumberFormatException ignored) {
}
}
return null;
......@@ -72,12 +80,15 @@ class JSON {
static Long toLong(Object value) {
if (value instanceof Long) {
return (Long) value;
} else if (value instanceof Number) {
}
else if (value instanceof Number) {
return ((Number) value).longValue();
} else if (value instanceof String) {
}
else if (value instanceof String) {
try {
return (long) Double.parseDouble((String) value);
} catch (NumberFormatException ignored) {
}
catch (NumberFormatException ignored) {
}
}
return null;
......@@ -86,7 +97,8 @@ class JSON {
static String toString(Object value) {
if (value instanceof String) {
return (String) value;
} else if (value != null) {
}
else if (value != null) {
return String.valueOf(value);
}
return null;
......@@ -96,7 +108,8 @@ class JSON {
String requiredType) throws JSONException {
if (actual == null) {
throw new JSONException("Value at " + indexOrName + " is null.");
} else {
}
else {
throw new JSONException("Value " + actual + " at " + indexOrName
+ " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
......@@ -107,7 +120,8 @@ class JSON {
throws JSONException {
if (actual == null) {
throw new JSONException("Value is null.");
} else {
}
else {
throw new JSONException("Value " + actual
+ " of type " + actual.getClass().getName()
+ " cannot be converted to " + requiredType);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment