Gets the int value associated with the specified index. @webref jsonarray:method @webBrief Gets the int value associated with the specified 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
(int index)
| 326 | * @see JSONArray#getBoolean(int) |
| 327 | */ |
| 328 | public int getInt(int index) { |
| 329 | Object object = this.get(index); |
| 330 | try { |
| 331 | return object instanceof Number |
| 332 | ? ((Number)object).intValue() |
| 333 | : Integer.parseInt((String)object); |
| 334 | } catch (Exception e) { |
| 335 | throw new RuntimeException("JSONArray[" + index + "] is not a number."); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | |
| 340 | /** |
no test coverage detected