Class JsonElement

java.lang.Object
com.azure.json.models.JsonElement
All Implemented Interfaces:
JsonSerializable<JsonElement>
Direct Known Subclasses:
JsonArray, JsonBoolean, JsonNull, JsonNumber, JsonObject, JsonString

public abstract class JsonElement extends Object implements JsonSerializable<JsonElement>
Interface defining methods that all JSON types must implement.
  • 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

      public JsonArray asArray()
      Casts the element to an array.

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

      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

      public JsonObject asObject()
      Casts the element to an object.

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

      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

      public JsonBoolean asBoolean()
      Casts the element to a boolean.

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

      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

      public JsonNull asNull()
      Casts the element to a null.

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

      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

      public JsonNumber asNumber()
      Casts the element to a number.

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

      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

      public JsonString asString()
      Casts the element to a string.

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

      Returns:
      The element as a string.