Get the int 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 is not a number.
(int index)
| 252 | * @throws JSONException If the key is not found or if the value is not a number. |
| 253 | */ |
| 254 | public int getInt(int index) throws JSONException { |
| 255 | Object object = get(index); |
| 256 | try { |
| 257 | return object instanceof Number ? |
| 258 | ((Number)object).intValue() : |
| 259 | Integer.parseInt((String)object); |
| 260 | } catch (Exception e) { |
| 261 | throw new JSONException("JSONArray[" + index + |
| 262 | "] is not a number."); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | |
| 267 | /** |
no test coverage detected