Get the double value associated with a key. @param key A key string. @return The numeric value. @throws RuntimeException if the key is not found or if the value is not a Number object and cannot be converted to a number.
(String key)
| 707 | * if the value is not a Number object and cannot be converted to a number. |
| 708 | */ |
| 709 | public double getDouble(String key) { |
| 710 | Object object = this.get(key); |
| 711 | try { |
| 712 | return object instanceof Number |
| 713 | ? ((Number)object).doubleValue() |
| 714 | : Double.parseDouble((String)object); |
| 715 | } catch (Exception e) { |
| 716 | throw new RuntimeException("JSONObject[" + quote(key) + "] is not a number."); |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | |
| 721 | /** |