public class JSONArray extends JSONGetter<Integer> implements JSON, List<Object>
| 构造器和说明 |
|---|
JSONArray()
Construct an empty JSONArray.
|
JSONArray(JSONTokener x)
Construct a JSONArray from a JSONTokener.
|
JSONArray(Object arrayOrCollection)
Construct a JSONArray from an array or Collection
|
JSONArray(String source)
Construct a JSONArray from a source JSON text.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
add(int index,
Object element) |
boolean |
add(Object e) |
boolean |
addAll(Collection<? extends Object> c) |
boolean |
addAll(int index,
Collection<? extends Object> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
equals(Object other)
Determine if two JSONArrays are similar.
|
Object |
get(int index) |
Object |
getObj(Integer index,
Object defaultValue)
获取Object属性值
|
int |
indexOf(Object o) |
boolean |
isEmpty() |
boolean |
isNull(int index)
Determine if the value is null.
|
Iterator<Object> |
iterator() |
String |
join(String separator)
Make a string from the contents of this JSONArray.
|
int |
lastIndexOf(Object o) |
ListIterator<Object> |
listIterator() |
ListIterator<Object> |
listIterator(int index) |
JSONArray |
put(int index,
Object value)
加入或者替换JSONArray中指定Index的值,如果index大于JSONArray的长度,将在指定index设置值,之前的位置填充JSONNull.Null
|
JSONArray |
put(Object value)
Append an object value.
|
Object |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
Object |
set(int index,
Object element) |
int |
size() |
List<Object> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
JSONObject |
toJSONObject(JSONArray names)
Produce a JSONObject by combining a JSONArray of names with the values of this JSONArray.
|
String |
toJSONString(int indentFactor)
Make a prettyprinted JSON text of this JSONArray.
|
String |
toString()
Make a JSON text of this JSONArray.
|
Writer |
write(Writer writer)
将JSON内容写入Writer,无缩进
Warning: This method assumes that the data structure is acyclical. |
Writer |
write(Writer writer,
int indentFactor,
int indent)
将JSON内容写入Writer
Warning: This method assumes that the data structure is acyclical. |
getJSONArray, getJSONObjectgetBigDecimal, getBigInteger, getBool, getByte, getChar, getDouble, getEnum, getFloat, getInt, getLong, getShort, getStrgetBigDecimal, getBigInteger, getBool, getByte, getChar, getDouble, getEnum, getFloat, getInt, getLong, getObj, getShort, getStrpublic JSONArray()
public JSONArray(JSONTokener x) throws JSONException
x - A JSONTokenerJSONException - If there is a syntax error.public JSONArray(String source) throws JSONException
source - A string that begins with [ (left bracket) and ends with ] (right bracket).JSONException - If there is a syntax error.public JSONArray(Object arrayOrCollection) throws JSONException
JSONException - If not an array.public boolean isNull(int index)
index - The index must be between 0 and size() - 1.public String join(String separator) throws JSONException
separator string is inserted between each element. Warning: This method assumes that the data structure is acyclical.separator - A string that will be inserted between the elements.JSONException - If the array contains an invalid number.public Object getObj(Integer index, Object defaultValue)
OptBasicTypeGettergetObj 在接口中 OptBasicTypeGetter<Integer>getObj 在类中 OptNullBasicTypeFromObjectGetter<Integer>index - 属性名defaultValue - 默认值public JSONArray put(Object value)
value - An object value. The value should be a Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the JSONNull.NULL object.public JSONArray put(int index, Object value) throws JSONException
index - 位置value - 值对象. 可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL.JSONException - index < 0 或者非有限的数字public boolean equals(Object other)
public JSONObject toJSONObject(JSONArray names) throws JSONException
names - A JSONArray containing a list of key strings. These will be paired with the values.JSONException - If any of the names are null.public String toString()
Warning: This method assumes that the data structure is acyclical.
public String toJSONString(int indentFactor) throws JSONException
toJSONString 在接口中 JSONindentFactor - The number of spaces to add to each level of indentation.[ (left bracket) and ending with ] (right
bracket).JSONExceptionpublic Writer write(Writer writer) throws JSONException
JSONwrite 在接口中 JSONwriter - WriterJSONExceptionpublic Writer write(Writer writer, int indentFactor, int indent) throws JSONException
JSONwrite 在接口中 JSONwriter - writerindentFactor - 每一级别的缩进量indent - 顶级别缩进量JSONExceptionpublic boolean isEmpty()
public boolean contains(Object o)
public Object[] toArray()
public <T> T[] toArray(T[] a)
public boolean remove(Object o)
public boolean containsAll(Collection<?> c)
containsAll 在接口中 Collection<Object>containsAll 在接口中 List<Object>public boolean addAll(Collection<? extends Object> c)
public boolean addAll(int index,
Collection<? extends Object> c)
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public int lastIndexOf(Object o)
lastIndexOf 在接口中 List<Object>public ListIterator<Object> listIterator()
listIterator 在接口中 List<Object>public ListIterator<Object> listIterator(int index)
listIterator 在接口中 List<Object>Copyright © 2017. All rights reserved.