Get the double value associated with an index. @param index must be between 0 and length() - 1 @return The value. @throws RuntimeException If the key is not found or if the value cannot be converted to a number.
(int index)
| 419 | * be converted to a number. |
| 420 | */ |
| 421 | public double getDouble(int index) { |
| 422 | Object object = this.get(index); |
| 423 | try { |
| 424 | return object instanceof Number |
| 425 | ? ((Number)object).doubleValue() |
| 426 | : Double.parseDouble((String)object); |
| 427 | } catch (Exception e) { |
| 428 | throw new RuntimeException("JSONArray[" + index + "] is not a number."); |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | |
| 433 | /** |
no test coverage detected