Get the long value associated with an index. @param index The index must be between 0 and length() - 1. @return The value. @throws JSONException If the key is not found or if the value cannot be converted to a number.
(int index)
| 336 | * to a number. |
| 337 | */ |
| 338 | public long getLong(int index) throws JSONException { |
| 339 | Object object = this.get(index); |
| 340 | try { |
| 341 | return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); |
| 342 | } catch (Exception e) { |
| 343 | throw new JSONException("JSONArray[" + index + "] is not a number."); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * Get the string associated with an index. |