Class JSON

    • Constructor Detail

      • JSON

        public JSON​(String json)
        Constructs a JSON object from a JSON string
        Parameters:
        json - the JSON string
      • JSON

        public JSON​(Map<String,​Object> values)
        Initializes the JSON with existed key-value pairs (usually not)
        Parameters:
        values - the JSON key-value pairs
    • Method Detail

      • createSection

        public JSONSection createSection​(String key)
        Description copied from interface: SectionMap
        Create the section named key Note: if the section named key already exists, it will be replaced by a new section
        Specified by:
        createSection in interface SectionMap
        Parameters:
        key - the key of the Section
        Returns:
        a section named key
      • getSection

        public JSONSection getSection​(String key)
        Description copied from interface: SectionMap
        Get the section named key Note: if the section named key does not exist, it will be created
        Specified by:
        getSection in interface SectionMap
        Parameters:
        key - the key of the Section
        Returns:
        the section named key
      • containsSection

        public boolean containsSection​(String key)
        Description copied from interface: SectionMap
        Indicate there is a section named key
        Specified by:
        containsSection in interface SectionMap
        Parameters:
        key - the key of the Section
        Returns:
        true there is a section named key, false otherwise
      • getList

        public JSONList getList​(String key)
        Description copied from class: JSONObject
        Get the list named key

        Note: this is for JSON only.

        Overrides:
        getList in class JSONObject
        Parameters:
        key - the key of the list
        Returns:
        a list named key
      • toJson

        public String toJson()
        Description copied from class: JSONObject
        Translate this JSON instance into json String
        Specified by:
        toJson in class JSONObject
        Returns:
        json String translated from this JSON instance
      • get

        public <T> T get​(String key)
        Description copied from class: JSONObject
        Get the value of the key-value pair

        Note: this is for JSON only.

        Specified by:
        get in interface SectionMap
        Overrides:
        get in class JSONObject
        Type Parameters:
        T - the type of the value
        Parameters:
        key - the key
        Returns:
        the value