Interface JsonBoolean
- All Superinterfaces:
JsonValue
The interface that represents the JSON boolean literals, "true" and "false".
A JsonBoolean can be created by parsing JSON text using either
Json.parse(String) or Json.parse(char[]).
Alternatively, of(boolean) can be used to
obtain a JsonBoolean.
- Since:
- 28
- External Specifications
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns thebooleanvalue represented by thisJsonValueif it is an instance ofJsonBoolean; otherwise, throws aJsonValueException.static JsonBooleanof(boolean src) Returns theJsonBooleancreated from the givenboolean.Methods declared in interface JsonValue
asDouble, asInt, asList, asLong, asMap, asString, get, get, toString, tryGet, tryValueModifier and TypeMethodDescriptiondefault doubleasDouble()Returns adoubleif thisJsonValueis an instance ofJsonNumberthat can be converted, as if byDouble.parseDouble, to a finitedoublevalue; otherwise, throws aJsonValueException.default intasInt()Returns anintif thisJsonValueis an instance ofJsonNumberthat can be converted exactly; otherwise, throws aJsonValueException.asList()Returns an unmodifiable list of theJsonValues if thisJsonValueis an instance ofJsonArray; otherwise, throws aJsonValueException.default longasLong()Returns alongif thisJsonValueis an instance ofJsonNumberthat can be converted exactly; otherwise, throws aJsonValueException.asMap()Returns an unmodifiable map ofStringtoJsonValueif thisJsonValueis an instance ofJsonObject; otherwise, throws aJsonValueException.default StringasString()Returns theStringvalue represented by thisJsonValueif it is an instance ofJsonString; otherwise, throws aJsonValueException.default JsonValueget(int index) Returns theJsonValueassociated with the given index if thisJsonValueis an instance ofJsonArray; otherwise, throws aJsonValueException.default JsonValueReturns theJsonValueassociated with the given member name if thisJsonValueis an instance ofJsonObject; otherwise, throws aJsonValueException.toString()Returns a String representation of thisJsonValuethat conforms to JSON syntax.Returns anOptionalcontaining the value of a given member of thisJsonObject, or an emptyOptionalif the member is absent; throwsJsonValueExceptionif thisJsonValueis not aJsonObject.tryValue()Returns anOptionalcontaining thisJsonValueif it is not an instance ofJsonNull, otherwise an emptyOptional.
-
Method Details
-
asBoolean
boolean asBoolean()Returns thebooleanvalue represented by thisJsonValueif it is an instance ofJsonBoolean; otherwise, throws aJsonValueException.- Specified by:
asBooleanin interfaceJsonValue- Returns:
- the
booleanvalue represented by thisJsonValueif it is an instance ofJsonBoolean; otherwise, throws aJsonValueException
-
of
Returns theJsonBooleancreated from the givenboolean.- Parameters:
src- the givenboolean.- Returns:
- the
JsonBooleancreated from the givenboolean
-