Package com.azure.json.models
Class JsonElement
java.lang.Object
com.azure.json.models.JsonElement
- All Implemented Interfaces:
JsonSerializable<JsonElement>
- Direct Known Subclasses:
JsonArray,JsonBoolean,JsonNull,JsonNumber,JsonObject,JsonString
Interface defining methods that all JSON types must implement.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasArray()Casts the element to an array.Casts the element to a boolean.asNull()Casts the element to a null.asNumber()Casts the element to a number.asObject()Casts the element to an object.asString()Casts the element to a string.booleanisArray()Indicates whether the element is an array.booleanIndicates whether the element is a boolean.booleanisNull()Indicates whether the element is a null.booleanisNumber()Indicates whether the element is a number.booleanisObject()Indicates whether the element is an object.booleanisString()Indicates whether the element is a string.Methods 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, toJson, toJsonBytes, toJsonString
-
Constructor Details
-
JsonElement
public JsonElement()Default constructor.
-
-
Method Details
-
isArray
public boolean isArray()Indicates whether the element is an array.- Returns:
- Whether the element is an array.
-
asArray
Casts the element to an array.If
isArray()returns false, this will throw aClassCastException.- Returns:
- The element as an array.
-
isObject
public boolean isObject()Indicates whether the element is an object.- Returns:
- Whether the element is an object.
-
asObject
Casts the element to an object.If
isObject()returns false, this will throw aClassCastException.- Returns:
- The element as an object.
-
isBoolean
public boolean isBoolean()Indicates whether the element is a boolean.- Returns:
- Whether the element is a boolean.
-
asBoolean
Casts the element to a boolean.If
isBoolean()returns false, this will throw aClassCastException.- Returns:
- The element as a boolean.
-
isNull
public boolean isNull()Indicates whether the element is a null.- Returns:
- Whether the element is a null.
-
asNull
Casts the element to a null.If
isNull()returns false, this will throw aClassCastException.- Returns:
- The element as a null.
-
isNumber
public boolean isNumber()Indicates whether the element is a number.- Returns:
- Whether the element is a number.
-
asNumber
Casts the element to a number.If
isNumber()returns false, this will throw aClassCastException.- Returns:
- The element as a number.
-
isString
public boolean isString()Indicates whether the element is a string.- Returns:
- Whether the element is a string.
-
asString
Casts the element to a string.If
isString()returns false, this will throw aClassCastException.- Returns:
- The element as a string.
-