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 Details

  • Constructor Details

    • JSONArray

      public JSONArray()
  • Method Details

    • size

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

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

      public String toString()
      Overrides:
      toString in class 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:
      IndexOutOfBoundsException - When there is no element at the specified position.
    • render

      protected String render(boolean aPretty, 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(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • strip

      public 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.