Get the long value associated with a key. @param key A key string. @return The long value. @throws RuntimeException if the key is not found or if the value cannot be converted to a long.
(String key)
| 647 | * be converted to a long. |
| 648 | */ |
| 649 | public long getLong(String key) { |
| 650 | Object object = this.get(key); |
| 651 | try { |
| 652 | return object instanceof Number |
| 653 | ? ((Number)object).longValue() |
| 654 | : Long.parseLong((String)object); |
| 655 | } catch (Exception e) { |
| 656 | throw new RuntimeException("JSONObject[" + quote(key) + "] is not a long.", e); |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | |
| 661 | /** |