Class JsonObject

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>, SequencedMap<String,Object>

public class JsonObject extends LinkedHashMap<String,Object>
Extends a LinkedHashMap with helper methods to determine the underlying JSON type of the map element.
See Also:
  • Constructor Details

    • JsonObject

      public JsonObject()
      Creates an empty JsonObject with the default capacity.
    • JsonObject

      public JsonObject(Map<? extends String,?> map)
      Creates a JsonObject from an existing Map.
    • JsonObject

      public JsonObject(int initialCapacity)
      Creates a JsonObject with the given initial capacity.
    • JsonObject

      public JsonObject(int initialCapacity, float loadFactor)
      Creates a JsonObject with the given initial capacity and load factor.
  • Method Details

    • builder

      public static JsonBuilder<JsonObject> builder()
      Creates a JsonBuilder for a JsonObject.
    • getArray

      public JsonArray getArray(String key)
      Returns the JsonArray at the given key, or null if it does not exist or is the wrong type.
    • getArray

      public JsonArray getArray(String key, JsonArray default_)
      Returns the JsonArray at the given key, or the default if it does not exist or is the wrong type.
    • getBoolean

      public boolean getBoolean(String key)
      Returns the Boolean at the given key, or false if it does not exist or is the wrong type.
    • getBoolean

      public boolean getBoolean(String key, Boolean default_)
      Returns the Boolean at the given key, or the default if it does not exist or is the wrong type.
    • getDouble

      public double getDouble(String key)
      Returns the Double at the given key, or 0.0 if it does not exist or is the wrong type.
    • getDouble

      public double getDouble(String key, double default_)
      Returns the Double at the given key, or the default if it does not exist or is the wrong type.
    • getFloat

      public float getFloat(String key)
      Returns the Float at the given key, or 0.0f if it does not exist or is the wrong type.
    • getFloat

      public float getFloat(String key, float default_)
      Returns the Float at the given key, or the default if it does not exist or is the wrong type.
    • getInt

      public int getInt(String key)
      Returns the Integer at the given key, or 0 if it does not exist or is the wrong type.
    • getInt

      public int getInt(String key, int default_)
      Returns the Integer at the given key, or the default if it does not exist or is the wrong type.
    • getLong

      public long getLong(String key)
      Returns the Long at the given key, or 0 if it does not exist or is the wrong type.
    • getLong

      public long getLong(String key, long default_)
      Returns the Long at the given key, or the default if it does not exist or is the wrong type.
    • getNumber

      public Number getNumber(String key)
      Returns the Number at the given key, or null if it does not exist or is the wrong type.
    • getNumber

      public Number getNumber(String key, Number default_)
      Returns the Number at the given key, or the default if it does not exist or is the wrong type.
    • getObject

      public JsonObject getObject(String key)
      Returns the JsonObject at the given key, or null if it does not exist or is the wrong type.
    • getObject

      public JsonObject getObject(String key, JsonObject default_)
      Returns the JsonObject at the given key, or the default if it does not exist or is the wrong type.
    • getString

      public String getString(String key)
      Returns the String at the given key, or null if it does not exist or is the wrong type.
    • getString

      public String getString(String key, String default_)
      Returns the String at the given key, or the default if it does not exist or is the wrong type.
    • has

      public boolean has(String key)
      Returns true if the object has an element at that key (even if that element is null).
    • isBoolean

      public boolean isBoolean(String key)
      Returns true if the object has a boolean element at that key.
    • isNull

      public boolean isNull(String key)
      Returns true if the object has a null element at that key.
    • isNumber

      public boolean isNumber(String key)
      Returns true if the object has a number element at that key.
    • isString

      public boolean isString(String key)
      Returns true if the object has a string element at that key.