Share via


JsonElement Class

  • java.lang.Object
    • com.azure.json.models.JsonElement

Implements

public abstract class JsonElement
implements JsonSerializable<JsonElement>

Interface defining methods that all JSON types must implement.

Constructor Summary

Constructor Description
JsonElement()

Default constructor.

Method Summary

Modifier and Type Method and Description
JsonArray asArray()

Casts the element to an array.

JsonBoolean asBoolean()

Casts the element to a boolean.

JsonNull asNull()

Casts the element to a null.

JsonNumber asNumber()

Casts the element to a number.

JsonObject asObject()

Casts the element to an object.

JsonString asString()

Casts the element to a string.

boolean isArray()

Indicates whether the element is an array.

boolean isBoolean()

Indicates whether the element is a boolean.

boolean isNull()

Indicates whether the element is a null.

boolean isNumber()

Indicates whether the element is a number.

boolean isObject()

Indicates whether the element is an object.

boolean isString()

Indicates whether the element is a string.

Methods inherited from java.lang.Object

Constructor Details

JsonElement

public JsonElement()

Default constructor.

Method Details

asArray

public JsonArray asArray()

Casts the element to an array.

If isArray() returns false, this will throw a ClassCastException.

Returns:

The element as an array.

asBoolean

public JsonBoolean asBoolean()

Casts the element to a boolean.

If isBoolean() returns false, this will throw a ClassCastException.

Returns:

The element as a boolean.

asNull

public JsonNull asNull()

Casts the element to a null.

If isNull() returns false, this will throw a ClassCastException.

Returns:

The element as a null.

asNumber

public JsonNumber asNumber()

Casts the element to a number.

If isNumber() returns false, this will throw a ClassCastException.

Returns:

The element as a number.

asObject

public JsonObject asObject()

Casts the element to an object.

If isObject() returns false, this will throw a ClassCastException.

Returns:

The element as an object.

asString

public JsonString asString()

Casts the element to a string.

If isString() returns false, this will throw a ClassCastException.

Returns:

The element as a string.

isArray

public boolean isArray()

Indicates whether the element is an array.

Returns:

Whether the element is an array.

isBoolean

public boolean isBoolean()

Indicates whether the element is a boolean.

Returns:

Whether the element is a boolean.

isNull

public boolean isNull()

Indicates whether the element is a null.

Returns:

Whether the element is a null.

isNumber

public boolean isNumber()

Indicates whether the element is a number.

Returns:

Whether the element is a number.

isObject

public boolean isObject()

Indicates whether the element is an object.

Returns:

Whether the element is an object.

isString

public boolean isString()

Indicates whether the element is a string.

Returns:

Whether the element is a string.

Applies to