Package com.alibaba.fastjson
Class JSONArray
- java.lang.Object
-
- com.alibaba.fastjson.JSON
-
- com.alibaba.fastjson.JSONArray
-
- All Implemented Interfaces:
JSONAware,Serializable,Cloneable,Iterable<Object>,Collection<Object>,List<Object>
public class JSONArray extends JSON implements List<Object>, Serializable, Cloneable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected TypecomponentTypeprotected ObjectrelatedArray-
Fields inherited from class com.alibaba.fastjson.JSON
DEFAULT_GENERATE_FEATURE, DEFAULT_PARSER_FEATURE, DEFAULT_TYPE_KEY, defaultLocale, defaultTimeZone, DEFFAULT_DATE_FORMAT, VERSION
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(int index, Object element)booleanadd(Object item)booleanaddAll(int index, Collection c)booleanaddAll(Collection c)voidclear()JSONArrayclone()booleancontains(Object o)booleancontainsAll(Collection c)booleanequals(Object obj)JSONArrayfluentAdd(Object e)JSONArrayfluentAddAll(Collection<?> c)JSONArrayfluentClear()JSONArrayfluentRemove(int index)JSONArrayfluentRemove(Object o)JSONArrayfluentRemoveAll(Collection<?> c)JSONArrayfluentSet(int index, Object element)Objectget(int index)BigDecimalgetBigDecimal(int index)BigIntegergetBigInteger(int index)BooleangetBoolean(int index)booleangetBooleanValue(int index)BytegetByte(int index)bytegetByteValue(int index)Returns a byte value at the specified location in thisJSONArray.TypegetComponentType()Deprecated.DategetDate(int index)DoublegetDouble(int index)doublegetDoubleValue(int index)Returns a double value at the specified location in thisJSONArray.FloatgetFloat(int index)floatgetFloatValue(int index)Returns a float value at the specified location in thisJSONArray.IntegergetInteger(int index)intgetIntValue(int index)JSONArraygetJSONArray(int index)JSONObjectgetJSONObject(int index)LonggetLong(int index)longgetLongValue(int index)<T> TgetObject(int index, Class<T> clazz)<T> TgetObject(int index, Type type)ObjectgetRelatedArray()Deprecated.ShortgetShort(int index)shortgetShortValue(int index)Returns a short value at the specified location in thisJSONArray.DategetSqlDate(int index)StringgetString(int index)TimestampgetTimestamp(int index)inthashCode()intindexOf(Object o)booleanisEmpty()Iteratoriterator()intlastIndexOf(Object o)ListIteratorlistIterator()ListIteratorlistIterator(int index)Objectremove(int index)booleanremove(Object o)booleanremoveAll(Collection c)booleanretainAll(Collection c)Objectset(int index, Object element)voidsetComponentType(Type componentType)Deprecated.voidsetRelatedArray(Object relatedArray)Deprecated.intsize()ListsubList(int fromIndex, int toIndex)Object[]toArray()Object[]toArray(Object[] a)<T> List<T>toJavaList(Class<T> clazz)<T> TtoJavaObject(Class<T> clazz)<T> TtoJavaObject(Type type)StringtoString()-
Methods inherited from class com.alibaba.fastjson.JSON
addMixInAnnotations, clearMixInAnnotations, configFilter, createReadContext, createReadContext, createWriteContext, getMixInAnnotations, isValid, isValidArray, isValidObject, parse, parse, parse, parse, parse, parse, parse, parse, parse, parseArray, parseArray, parseArray, parseArray, parseArray, parseArray, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, parseObject, removeMixInAnnotations, toJavaObject, toJavaObject, toJSON, toJSON, toJSON, toJSONBytes, toJSONBytes, toJSONBytes, toJSONBytes, toJSONBytes, toJSONBytes, toJSONBytes, toJSONBytes, toJSONBytes, toJSONBytes, toJSONBytes, toJSONBytes, toJSONBytes, toJSONString, toJSONString, toJSONString, toJSONString, toJSONString, toJSONString, toJSONString, toJSONString, toJSONString, toJSONString, toJSONString, toJSONString, toJSONStringWithDateFormat, toJSONStringZ, toString, writeJSONString, writeJSONString, writeJSONString, writeJSONString, writeJSONString, writeJSONString, writeJSONString, writeJSONString, writeJSONString, writeJSONString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
-
-
-
Constructor Detail
-
JSONArray
public JSONArray()
-
JSONArray
public JSONArray(List list)
-
JSONArray
public JSONArray(int initialCapacity)
-
-
Method Detail
-
getByte
public Byte getByte(int index)
-
getShort
public Short getShort(int index)
-
getFloat
public Float getFloat(int index)
-
getDouble
public Double getDouble(int index)
-
getIntValue
public int getIntValue(int index)
-
getBigDecimal
public BigDecimal getBigDecimal(int index)
-
getLongValue
public long getLongValue(int index)
-
getInteger
public Integer getInteger(int index)
-
getLong
public Long getLong(int index)
-
getBooleanValue
public boolean getBooleanValue(int index)
-
getBoolean
public Boolean getBoolean(int index)
-
getJSONObject
public JSONObject getJSONObject(int index)
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
-
iterator
public Iterator iterator()
-
toArray
public Object[] toArray()
-
add
public boolean add(Object item)
-
remove
public boolean remove(Object o)
-
addAll
public boolean addAll(Collection c)
-
addAll
public boolean addAll(int index, Collection c)
-
clear
public void clear()
-
fluentClear
public JSONArray fluentClear()
-
fluentRemove
public JSONArray fluentRemove(int index)
-
fluentRemoveAll
public JSONArray fluentRemoveAll(Collection<?> c)
-
fluentAddAll
public JSONArray fluentAddAll(Collection<?> c)
-
getShortValue
public short getShortValue(int index)
Returns a short value at the specified location in thisJSONArray.- Parameters:
index- index of the element to return- Returns:
- short
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable shortJSONException- Unsupported type conversion to short valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getFloatValue
public float getFloatValue(int index)
Returns a float value at the specified location in thisJSONArray.- Parameters:
index- index of the element to return- Returns:
- float
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable floatJSONException- Unsupported type conversion to float valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getDoubleValue
public double getDoubleValue(int index)
Returns a double value at the specified location in thisJSONArray.- Parameters:
index- index of the element to return- Returns:
- double
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable doubleJSONException- Unsupported type conversion to double valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
retainAll
public boolean retainAll(Collection c)
-
removeAll
public boolean removeAll(Collection c)
-
containsAll
public boolean containsAll(Collection c)
- Specified by:
containsAllin interfaceCollection<Object>- Specified by:
containsAllin interfaceList<Object>
-
getByteValue
public byte getByteValue(int index)
Returns a byte value at the specified location in thisJSONArray.- Parameters:
index- index of the element to return- Returns:
- byte
- Throws:
NumberFormatException- If the value of get isStringand it contains no parsable byteJSONException- Unsupported type conversion to byte valueIndexOutOfBoundsException- if the index is out of range(index < 0 || index >= size())
-
getBigInteger
public BigInteger getBigInteger(int index)
-
getSqlDate
public Date getSqlDate(int index)
-
getTimestamp
public Timestamp getTimestamp(int index)
-
getDate
public Date getDate(int index)
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOfin interfaceList<Object>
-
listIterator
public ListIterator listIterator()
- Specified by:
listIteratorin interfaceList<Object>
-
listIterator
public ListIterator listIterator(int index)
- Specified by:
listIteratorin interfaceList<Object>
-
subList
public List subList(int fromIndex, int toIndex)
-
getString
public String getString(int index)
-
getJSONArray
public JSONArray getJSONArray(int index)
-
getObject
public <T> T getObject(int index, Type type)
-
getObject
public <T> T getObject(int index, Class<T> clazz)
-
toJavaObject
public <T> T toJavaObject(Class<T> clazz)
- Specified by:
toJavaObjectin classJSON
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object obj)
-
toJavaObject
public <T> T toJavaObject(Type type)
- Specified by:
toJavaObjectin classJSON
-
getComponentType
@Deprecated public Type getComponentType()
Deprecated.
-
setComponentType
@Deprecated public void setComponentType(Type componentType)
Deprecated.
-
getRelatedArray
@Deprecated public Object getRelatedArray()
Deprecated.
-
setRelatedArray
@Deprecated public void setRelatedArray(Object relatedArray)
Deprecated.
-
-