Get the boolean value associated with an index. The string values "true" and "false" are converted to boolean. @webref jsonarray:method @brief Gets the boolean value associated with an index @param index must be between 0 and length() - 1 @return The truth. @throws RuntimeException If there is
(int index)
| 463 | * @see JSONArray#getString(int) |
| 464 | */ |
| 465 | public boolean getBoolean(int index) { |
| 466 | Object object = this.get(index); |
| 467 | if (object.equals(Boolean.FALSE) || |
| 468 | (object instanceof String && |
| 469 | ((String)object).equalsIgnoreCase("false"))) { |
| 470 | return false; |
| 471 | } else if (object.equals(Boolean.TRUE) || |
| 472 | (object instanceof String && |
| 473 | ((String)object).equalsIgnoreCase("true"))) { |
| 474 | return true; |
| 475 | } |
| 476 | throw new RuntimeException("JSONArray[" + index + "] is not a boolean."); |
| 477 | } |
| 478 | |
| 479 | |
| 480 | /** |
no test coverage detected