Class JsonObject

java.lang.Object
name.martingeisse.grumpyjson.json_model.JsonElement
name.martingeisse.grumpyjson.json_model.JsonObject

public abstract class JsonObject extends JsonElement
This class represents JSON objects.
  • Method Details

    • of

      public static JsonObject of(Map<String,JsonElement> properties)
      Creates an instance of this class from a Map containing the properties of the JSON object.
      Parameters:
      properties - the properties of the JSON object to create
      Returns:
      the JSON object
    • of

      public static JsonObject of()
      Creates an empty instance of this class.
      Returns:
      the JSON object
    • of

      public static JsonObject of(String key1, JsonElement value1)
      Creates an instance of this class from one directly specified key/value pair.
      Parameters:
      key1 - the first property key
      value1 - the first property value
      Returns:
      the JSON object
    • of

      public static JsonObject of(String key1, JsonElement value1, String key2, JsonElement value2)
      Creates an instance of this class from two directly specified key/value pairs.
      Parameters:
      key1 - the first property key
      value1 - the first property value
      key2 - the second property key
      value2 - the second property value
      Returns:
      the JSON object
    • of

      public static JsonObject of(String key1, JsonElement value1, String key2, JsonElement value2, String key3, JsonElement value3)
      Creates an instance of this class from three directly specified key/value pairs.
      Parameters:
      key1 - the first property key
      value1 - the first property value
      key2 - the second property key
      value2 - the second property value
      key3 - the second property key
      value3 - the second property value
      Returns:
      the JSON object
    • getAsMap

      public abstract Map<String,JsonElement> getAsMap()
      Returns the properties of this JSON object as a Map.
      Returns:
      the properties
    • deserializerExpectsObject

      public final Map<String,JsonElement> deserializerExpectsObject()
      Description copied from class: JsonElement
      If this JSON element is not a JSON object, this method throws a JsonDeserializationException, otherwise it returns the array's elements as a Map.
      Overrides:
      deserializerExpectsObject in class JsonElement
      Returns:
      the property map
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object