Get the double value associated with an index. @param index The index must be between 0 and length() - 1. @return The value. @throws JSONException If the key is not found or if the value cannot be converted to a number.
(int index)
| 232 | * be converted to a number. |
| 233 | */ |
| 234 | public double getDouble(int index) throws JSONException { |
| 235 | Object object = get(index); |
| 236 | try { |
| 237 | return object instanceof Number ? |
| 238 | ((Number)object).doubleValue() : |
| 239 | Double.parseDouble((String)object); |
| 240 | } catch (Exception e) { |
| 241 | throw new JSONException("JSONArray[" + index + |
| 242 | "] is not a number."); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | |
| 247 | /** |
no test coverage detected