Class JsonBoolean
- All Implemented Interfaces:
JsonSerializable<JsonElement>
-
Method Summary
Modifier and TypeMethodDescriptionstatic JsonBooleanfromJson(JsonReader jsonReader) Deserializes a JSON boolean from a JsonReader.static JsonBooleangetInstance(boolean value) Gets the instance of JsonBoolean for the specified boolean value.booleangetValue()Returns boolean value from a JsonBoolean object.booleanIdentifies if an object is of type JsonBoolean.toJson(JsonWriter jsonWriter) Writes the object to the passedJsonWriter.Convenience method for writing theJsonSerializableto a JSON string.Methods inherited from class com.azure.json.models.JsonElement
asArray, asBoolean, asNull, asNumber, asObject, asString, isArray, isNull, isNumber, isObject, isStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.azure.json.JsonSerializable
toJson, toJson, toJsonBytes
-
Method Details
-
getInstance
Gets the instance of JsonBoolean for the specified boolean value.- Parameters:
value- The boolean value for which to obtain the JsonBoolean instance.- Returns:
- The instance of JsonBoolean representing the specified boolean value.
-
getValue
public boolean getValue()Returns boolean value from a JsonBoolean object.- Returns:
- The boolean value.
-
isBoolean
public boolean isBoolean()Identifies if an object is of type JsonBoolean.- Overrides:
isBooleanin classJsonElement- Returns:
- boolean of whether this JsonElement object is of type JsonBoolean.
-
toJson
Description copied from interface:JsonSerializableWrites the object to the passedJsonWriter.The contract for writing JSON to
JsonWriteris that the object being written will handle opening and closing its own JSON object. So, for objects calling out to otherJsonSerializableobjects for serialization, they'll write the field name only then pass theJsonWriterto the otherJsonSerializableobject. This way objects writing JSON will be self-encapsulated for writing properly formatted JSON.- Parameters:
jsonWriter- Where the object's JSON will be written.- Returns:
- The
JsonWriterwhere the JSON was written. - Throws:
IOException- If the object fails to be written to thejsonWriter.
-
fromJson
Deserializes a JSON boolean from a JsonReader.If the JsonReader's current token is null, it is assumed the JsonReader hasn't begun reading and
JsonReader.nextToken()will be called to begin reading.After ensuring the JsonReader has begun reading, if the current token is not
JsonToken.BOOLEAN, anIllegalStateExceptionwill be thrown. Otherwise,getInstance(boolean)will be called to return the deserialized JSON boolean.- Parameters:
jsonReader- The JsonReader to deserialize from.- Returns:
- The deserialized JSON boolean.
- Throws:
IOException- If an error occurs while deserializing the JSON boolean.IllegalStateException- If the current token is notJsonToken.BOOLEAN.
-
toJsonString
Description copied from interface:JsonSerializableConvenience method for writing theJsonSerializableto a JSON string.- Returns:
- The JSON string representing the object.
- Throws:
IOException- If the object fails to be written as a JSON string.
-