Class JSONArray


  • public class JSONArray
    extends JSONComplex
    Represents a JSON array (list), an ordered list of values ... Example: [ "one", "two", "tree" ] is an array of 3 strings.
    • Field Detail

      • array

        private java.util.List<JSONValue> array
    • Constructor Detail

      • JSONArray

        public JSONArray()
    • Method Detail

      • size

        public int size()
        Specified by:
        size in class JSONComplex
        Returns:
        The length of the array (list).
      • getValue

        public java.util.List<JSONValue> getValue()
        Returns:
        The JSON elements in the array (list).
      • toString

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

        public JSONValue get​(int i)
        Utility method, get an element at a specific position in the list. You do not have to get the list value first with getValue() first.
        Parameters:
        i - Index of the element to return.
        Returns:
        Returns the element at the specified position in this list.
        Throws:
        java.lang.IndexOutOfBoundsException - When there is no element at the specified position.
      • 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
      • strip

        public java.lang.Object strip()
        Remove all JSON information. In the case of a JSONString, a Java String is returned. The elements of the array are stripped as well.
        Specified by:
        strip in class JSONValue
        Returns:
        A Java String representing the contents of the JSONString.