Package org.javalite.json
Class JSONList
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList
org.javalite.json.JSONList
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable
,Collection
,List
,RandomAccess
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
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetBigDecimal(int index)
boolean
getBoolean(int index)
getDate(int index)
getDouble(int index)
getFloat(int index)
getInteger(int index)
getList(int index)
Returns aJSONList
at a provided index.getLong(int index)
getMap(int index)
Returns a JSONMap at a provided index.getShort(int index)
getString(int index)
toJSON(boolean pretty)
toString()
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll
-
Constructor Details
-
JSONList
-
JSONList
-
JSONList
public JSONList()
-
-
Method Details
-
getMap
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
Returns aJSONList
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
-
getDate
-
getDouble
-
getFloat
-
getInteger
-
getLong
-
getShort
-
getString
-
toString
- Overrides:
toString
in classAbstractCollection
- Returns:
- a JSON representation of this object
-
toJSON
- Parameters:
pretty
- - true for formatted JSON.- Returns:
- a JSON representation of this object
-