Get the long value associated with an index. @param index The 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)
| 357 | * be converted to a number. |
| 358 | */ |
| 359 | public long getLong(int index) { |
| 360 | Object object = this.get(index); |
| 361 | try { |
| 362 | return object instanceof Number |
| 363 | ? ((Number)object).longValue() |
| 364 | : Long.parseLong((String)object); |
| 365 | } catch (Exception e) { |
| 366 | throw new RuntimeException("JSONArray[" + index + "] is not a number."); |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | |
| 371 | /** |