Get the boolean value associated with a key. @webref jsonobject:method @brief Gets the boolean value associated with a key @param key a key string @return The truth. @throws RuntimeException if the value is not a Boolean or the String "true" or "false". @see JSONObject#getInt(String) @see JSONObjec
(String key)
| 750 | * @see JSONObject#getString(String) |
| 751 | */ |
| 752 | public boolean getBoolean(String key) { |
| 753 | Object object = this.get(key); |
| 754 | if (object.equals(Boolean.FALSE) || |
| 755 | (object instanceof String && |
| 756 | ((String)object).equalsIgnoreCase("false"))) { |
| 757 | return false; |
| 758 | } else if (object.equals(Boolean.TRUE) || |
| 759 | (object instanceof String && |
| 760 | ((String)object).equalsIgnoreCase("true"))) { |
| 761 | return true; |
| 762 | } |
| 763 | throw new RuntimeException("JSONObject[" + quote(key) + "] is not a Boolean."); |
| 764 | } |
| 765 | |
| 766 | |
| 767 | /** |