Share via


JsonBoolean Class

public final class JsonBoolean
extends JsonElement

Model representing a JSON boolean value.

Method Summary

Modifier and Type Method and Description
static JsonBoolean fromJson(JsonReader jsonReader)

Deserializes a JSON boolean from a JsonReader.

static JsonBoolean getInstance(boolean value)

Gets the instance of JsonBoolean for the specified boolean value.

boolean getValue()

Returns boolean value from a JsonBoolean object.

boolean isBoolean()

Identifies if an object is of type JsonBoolean.

JsonWriter toJson(JsonWriter jsonWriter)
String toJsonString()

Methods inherited from JsonElement

Methods inherited from java.lang.Object

Method Details

fromJson

public static JsonBoolean fromJson(JsonReader jsonReader)

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 nextToken() will be called to begin reading.

After ensuring the JsonReader has begun reading, if the current token is not BOOLEAN, an IllegalStateException will be thrown. Otherwise, getInstance(boolean value) 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.

getInstance

public static JsonBoolean getInstance(boolean value)

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:

JsonBoolean.isBoolean()

Returns:

boolean of whether this JsonElement object is of type JsonBoolean.

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

toJsonString

public String toJsonString()

Throws:

Applies to