From 04d6e83fc215001decb989a9223ac7c983383e8f Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Fri, 19 May 2017 09:49:22 -0400 Subject: [PATCH] * Missed JSONArray optFloat and optDouble for the revert * prevents erasure of stack trace for rethrown exceptions --- JSONArray.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/JSONArray.java b/JSONArray.java index 2783bf7..a1147e7 100644 --- a/JSONArray.java +++ b/JSONArray.java @@ -244,7 +244,7 @@ public class JSONArray implements Iterable { return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object); } catch (Exception e) { - throw new JSONException("JSONArray[" + index + "] is not a number."); + throw new JSONException("JSONArray[" + index + "] is not a number.", e); } } @@ -287,7 +287,7 @@ public class JSONArray implements Iterable { } return JSONObject.stringToNumber(object.toString()); } catch (Exception e) { - throw new JSONException("JSONArray[" + index + "] is not a number."); + throw new JSONException("JSONArray[" + index + "] is not a number.", e); } } @@ -331,7 +331,7 @@ public class JSONArray implements Iterable { return new BigDecimal(object.toString()); } catch (Exception e) { throw new JSONException("JSONArray[" + index + - "] could not convert to BigDecimal."); + "] could not convert to BigDecimal.", e); } } @@ -351,7 +351,7 @@ public class JSONArray implements Iterable { return new BigInteger(object.toString()); } catch (Exception e) { throw new JSONException("JSONArray[" + index + - "] could not convert to BigInteger."); + "] could not convert to BigInteger.", e); } } @@ -370,7 +370,7 @@ public class JSONArray implements Iterable { return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object); } catch (Exception e) { - throw new JSONException("JSONArray[" + index + "] is not a number."); + throw new JSONException("JSONArray[" + index + "] is not a number.", e); } } @@ -426,7 +426,7 @@ public class JSONArray implements Iterable { return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); } catch (Exception e) { - throw new JSONException("JSONArray[" + index + "] is not a number."); + throw new JSONException("JSONArray[" + index + "] is not a number.", e); } } @@ -569,7 +569,7 @@ public class JSONArray implements Iterable { } if (val instanceof String) { try { - return new BigDecimal((String) val).doubleValue(); + return Double.parseDouble((String) val); } catch (Exception e) { return defaultValue; } @@ -611,7 +611,7 @@ public class JSONArray implements Iterable { } if (val instanceof String) { try { - return new BigDecimal((String) val).floatValue(); + return Float.parseFloat((String) val); } catch (Exception e) { return defaultValue; }