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)
| 363 | * be converted to a number. |
| 364 | */ |
| 365 | public long getLong(int index) { |
| 366 | Object object = this.get(index); |
| 367 | try { |
| 368 | return object instanceof Number |
| 369 | ? ((Number)object).longValue() |
| 370 | : Long.parseLong((String)object); |
| 371 | } catch (Exception e) { |
| 372 | throw new RuntimeException("JSONArray[" + index + "] is not a number."); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | |
| 377 | /** |