Class JSONObject


  • public class JSONObject
    extends JSONComplex
    Representation of a JSON object, a collection (unordered) of name/value pairs. An example: {"name":"Homer", "age":40, "children":["Bart", "Maggie", "Lisa"]}
    • Field Detail

      • map

        private java.util.HashMap<java.lang.String,​JSONValue> map
    • Constructor Detail

      • JSONObject

        public JSONObject()
    • Method Detail

      • getValue

        public java.util.HashMap<java.lang.String,​JSONValue> getValue()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • render

        protected java.lang.String render​(boolean aPretty,
                                          java.lang.String aIndent)
        Description copied from class: JSONValue
        Convert the JSON value into a string representation (JSON representation).
        Specified by:
        render in class JSONValue
        Parameters:
        aPretty - Indicating if the print should be made pretty (human readers) or compact (transmission or storage).
        aIndent - Starting indent.
        Returns:
        A JSON representation.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • containsKey

        public boolean containsKey​(java.lang.String aKey)
      • get

        public JSONValue get​(java.lang.String aKey)
        Utility method, get the element with specified name without having to retreive the map first using getValue().
        Parameters:
        aKey - The key for which you want to retrieve the element.
        Returns:
        The element corresponding to the key or null if the object does not contain a key with this name.
      • strip

        public java.lang.Object strip()
        Remove all JSON related information. In the case of a JSONObject, a HashMap is returned. The values of the HashMap are stripped as well.
        Specified by:
        strip in class JSONValue
        Returns:
        a HashMap, containing pure Java objects.