Class JSONList

All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess

public class JSONList extends ArrayList
Represents a java.util.List as an object that fronts a chunk of a JSON object. A list can contain all kinds of things normally found in JSON: other lists, maps, primitives, etc.

This class adds getList(int) and getMap(int) for convenience when working with JSON.
See Also:
getList(int), getMap(int), Serialized Form
  • Constructor Details

    • JSONList

      public JSONList(List jsonList)
    • JSONList

      public JSONList(String jsonList)
    • JSONList

      public JSONList()
  • Method Details

    • getMap

      public JSONMap getMap(int index)
      Returns a JSONMap at a provided index. If the object is not a map, it will throw an exception.
      Parameters:
      index - index at which to look for a map.
      Returns:
      instance of JSONMap at a specified index.
    • getList

      public JSONList getList(int index)
      Returns a JSONList at a provided index. If the object is not a list, it will throw an exception.
      Parameters:
      index - index at which to look for a list.
      Returns:
      instance of JSONList at a specified index.
    • getBoolean

      public boolean getBoolean(int index)
    • getBigDecimal

      public BigDecimal getBigDecimal(int index)
    • getDate

      public Date getDate(int index)
    • getDouble

      public Double getDouble(int index)
    • getFloat

      public Float getFloat(int index)
    • getInteger

      public Integer getInteger(int index)
    • getLong

      public Long getLong(int index)
    • getShort

      public Short getShort(int index)
    • getString

      public String getString(int index)
    • toString

      public String toString()
      Overrides:
      toString in class AbstractCollection
      Returns:
      a JSON representation of this object
    • toJSON

      public String toJSON(boolean pretty)
      Parameters:
      pretty - - true for formatted JSON.
      Returns:
      a JSON representation of this object