Class JSONValueObject

    • Method Detail

      • get

        public abstract JSONValue get​(JSONValueString name)
        Returns the JSON value of the given name.

        If a value of the given name does not exist, this method returns null. Do not confuse it with a JSON 'null' value. If there is a JSON 'null' value of the given name, this method returns an instance of JSONValueNull instead.

        Parameters:
        name - a JSON string value which represents a name
        Returns:
        a JSON value of the given name
      • get

        public abstract JSONValue get​(String name)
        Returns the JSON value which has the given name.
        Parameters:
        name - name
        Returns:
        a JSON value of the given name
        See Also:
        get(JSONValueString)
      • containsKey

        public abstract boolean containsKey​(String name)
        Check if this JSON object has a value which has the given name.
        Parameters:
        name - name
        Returns:
        true if a value with the given name exists
        See Also:
        containsKey(Object)
      • put

        public JSONValue put​(String key,
                             JSONValue value)
        Associates the specified value with the specified key in this JSON object.
        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
        Returns:
        the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
      • put

        public JSONValue put​(String key,
                             boolean value)
        Associates the specified boolean value with the specified key in this JSON object.
        Parameters:
        key - key with which the specified value is to be associated
        value - booolean value to be associated with the specified key
        Returns:
        the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
      • put

        public JSONValue put​(String key,
                             long value)
        Associates the specified number value with the specified key in this JSON object.
        Parameters:
        key - key with which the specified value is to be associated
        value - number value to be associated with the specified key
        Returns:
        the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
      • put

        public JSONValue put​(String key,
                             double value)
        Associates the specified number value with the specified key in this JSON object.
        Parameters:
        key - key with which the specified value is to be associated
        value - number value to be associated with the specified key
        Returns:
        the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
      • put

        public JSONValue put​(String key,
                             String value)
        Associates the specified string value with the specified key in this JSON object.
        Parameters:
        key - key with which the specified value is to be associated
        value - string alue to be associated with the specified key. Null is considered as an empty string.
        Returns:
        the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
      • getBoolean

        public boolean getBoolean​(String key)
        Returns the boolean value to which the specified key is mapped, or null if this map contains no mapping for the key.
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        the value to which the specified key is mapped
        Throws:
        WrongValueTypeException - if the value type is not boolean
        IllegalArgumentException - if this object contains no mapping for the key
      • getLong

        public long getLong​(String key)
        Returns the long value to which the specified key is mapped, or null if this map contains no mapping for the key.
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        the value to which the specified key is mapped
        Throws:
        WrongValueTypeException - if the value type is not number
        NumberFormatException - if the value cannot be converted to a Java long value
        IllegalArgumentException - if this object contains no mapping for the key
      • getDouble

        public double getDouble​(String key)
        Returns the double value to which the specified key is mapped, or null if this map contains no mapping for the key.
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        the value to which the specified key is mapped
        Throws:
        WrongValueTypeException - if the value type is not number
        IllegalArgumentException - if this object contains no mapping for the key
      • getString

        public String getString​(String key)
        Returns the string value to which the specified key is mapped, or null if this map contains no mapping for the key.
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        the value to which the specified key is mapped
        Throws:
        WrongValueTypeException - if the value type is not string
        IllegalArgumentException - if this object contains no mapping for the key
      • getArray

        public JSONValueArray getArray​(String key)
        Returns the array value to which the specified key is mapped, or null if this map contains no mapping for the key.
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        the value to which the specified key is mapped
        Throws:
        WrongValueTypeException - if the value type is not array
        IllegalArgumentException - if this object contains no mapping for the key
      • getObject

        public JSONValueObject getObject​(String key)
        Returns the object value to which the specified key is mapped, or null if this map contains no mapping for the key.
        Parameters:
        key - the key whose associated value is to be returned
        Returns:
        the value to which the specified key is mapped
        Throws:
        WrongValueTypeException - if the value type is not object
        IllegalArgumentException - if this object contains no mapping for the key