Get the int value associated with an index. @webref jsonarray:method @brief Gets the int value associated with an index @param index must be between 0 and length() - 1 @return The value. @throws RuntimeException If the key is not found or if the value is not a number. @see JSONArray#getFloat(int) @
(int index)
| 320 | * @see JSONArray#getBoolean(int) |
| 321 | */ |
| 322 | public int getInt(int index) { |
| 323 | Object object = this.get(index); |
| 324 | try { |
| 325 | return object instanceof Number |
| 326 | ? ((Number)object).intValue() |
| 327 | : Integer.parseInt((String)object); |
| 328 | } catch (Exception e) { |
| 329 | throw new RuntimeException("JSONArray[" + index + "] is not a number."); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | |
| 334 | /** |
no test coverage detected