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)
| 307 | * be converted to a number. |
| 308 | */ |
| 309 | public long getLong(int index) throws JSONException { |
| 310 | Object object = get(index); |
| 311 | try { |
| 312 | return object instanceof Number ? |
| 313 | ((Number)object).longValue() : |
| 314 | Long.parseLong((String)object); |
| 315 | } catch (Exception e) { |
| 316 | throw new JSONException("JSONArray[" + index + |
| 317 | "] is not a number."); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | |
| 322 | /** |
no test coverage detected