Class JsonElement


  • public class JsonElement
    extends Object
    A JsonElement is the Object used by JsonArrays and JsonObjects in their respective collections, to make the use of the enhanced for loop more easy to use. To do so JsonElement contains getAsX() methods to prevent the need of casting on the user end.
    • Constructor Detail

      • JsonElement

        public JsonElement​(JsonValue value)
        Creates a new JsonElement holding the passed JsonValue.
        Parameters:
        value - the value
    • Method Detail

      • isNull

        public boolean isNull()
        Checks if the JsonElement is JSON null
        Returns:
        true if the JsonElement is null; false otherwise
      • isBoolean

        public boolean isBoolean()
        Checks if the JsonElement represents a boolean.
        Returns:
        true if the JsonElement represents a boolean; false otherwise
      • isCharacter

        public boolean isCharacter()
        Checks if the JsonElement represents a character.
        Returns:
        true if the JsonElement represents a character; false otherwise
      • isNumber

        public boolean isNumber()
        Checks if the JsonElement represents a Number.
        Returns:
        true if the JsonElement represents a Number; false otherwise
      • isString

        public boolean isString()
        Checks if the JsonElement represents a String.
        Returns:
        true if the JsonElement represents a String; false otherwise
      • isJsonArray

        public boolean isJsonArray()
        Checks if the JsonElement represents a JsonArray.
        Returns:
        true if the JsonElement represents a JsonArray; false otherwise
      • isJsonObject

        public boolean isJsonObject()
        Checks if the JsonElement represents a JsonObject.
        Returns:
        true if the JsonElement represents a JsonObject; false otherwise
      • equals

        public boolean equals​(Object o)
        Checks, whether or not this JsonElement is equal to the provided Object o.
        Overrides:
        equals in class Object
        Parameters:
        o - the Object that is to be compared with this JsonElement
        Returns:
        true if Object o and this JsonElement are equal; false otherwise
      • hashCode

        public int hashCode()
        Generates a hash code that is unique to every object, that is not equal to one another, as defined by equals(Object), but is the same for every JsonElement that is equal.
        Overrides:
        hashCode in class Object
        Returns:
        the hash code
      • toString

        public String toString()
        Returns a String representation of this JsonElement.
        Overrides:
        toString in class Object
        Returns:
        a String representation of this JsonElement