public class JSONArray extends ListWrapper<JSON> implements JSON, JSONGetter<Integer>, RandomAccess
["a", "b", "c", 12]
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CAPACITY
默认初始大小
|
raw| Constructor and Description |
|---|
JSONArray()
构造
默认使用 ArrayList 实现 |
JSONArray(int initialCapacity)
构造
默认使用 ArrayList 实现 |
JSONArray(int initialCapacity,
JSONConfig config)
构造
默认使用 ArrayList 实现 |
JSONArray(int initialCapacity,
JSONFactory factory)
构造
默认使用 ArrayList 实现 |
JSONArray(JSONConfig config)
构造
默认使用 ArrayList 实现 |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
JSON element) |
boolean |
add(JSON element) |
boolean |
addAll(int index,
Collection<? extends JSON> c) |
JSONArray |
addNull()
加入
null元素,如果设置中忽略null值,则忽略 |
JSONArray |
addValue(Boolean value)
加入元素,数组长度+1,等同于
ListWrapper.add(Object) |
JSONArray |
addValue(Character value)
加入元素,数组长度+1,等同于
ListWrapper.add(Object) |
JSONArray |
addValue(Number value)
加入元素,数组长度+1,等同于
ListWrapper.add(Object) |
JSONArray |
addValue(Object value)
加入元素,数组长度+1,等同于
ListWrapper.add(Object) |
JSONArray |
addValue(String value)
加入元素,数组长度+1,等同于
ListWrapper.add(Object) |
JSONFactory |
getFactory()
获取JSON工厂
|
JSON |
getJSON(Integer key)
获取JSON对象
在JSON树模型中,JSON的节点都以JSON格式存储,所有get方法都基于此方法 |
Iterator<JSON> |
iterator() |
JSON |
set(int index,
JSON element)
加入或者替换JSONArray中指定Index的值,如果index大于JSONArray的长度,将在指定index设置值,之前的位置填充JSONNull.Null
|
JSONArray |
setValue(int index,
Object element)
加入或者替换JSONArray中指定Index的值,如果index大于JSONArray的长度,将在指定index设置值,之前的位置填充JSONNull.Null
|
Object |
toArray(Class<?> arrayClass)
转为Bean数组
|
<T> T[] |
toArray(T[] a) |
JSONObject |
toJSONObject(JSONArray names)
根据给定名列表,与其位置对应的值组成JSONObject
|
<T> List<T> |
toList(Class<T> elementType)
|
String |
toString()
转为JSON字符串,无缩进
|
void |
write(JSONWriter writer)
将JSON内容写入Writer
Warning: This method assumes that the data structure is acyclical. |
addAll, clear, contains, containsAll, equals, forEach, get, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, parallelStream, remove, remove, removeAll, removeIf, replaceAll, retainAll, size, sort, spliterator, stream, subList, toArraygetRawclone, finalize, getClass, notify, notifyAll, wait, wait, waitasJSONArray, asJSONObject, asJSONPrimitive, config, getByPath, getByPath, getObjByPath, isEmpty, putByPath, size, toBean, toJSONString, toJSONString, toStringPrettyget, getBeanList, getJSONArray, getJSONObject, getObj, getStrEscaped, getStrEscaped, isNullget, get, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBool, getBool, getByte, getByte, getBytes, getBytes, getChar, getChar, getDate, getDate, getDouble, getDouble, getEnum, getEnum, getFloat, getFloat, getInt, getInt, getLocalDate, getLocalDate, getLocalDateTime, getLocalDateTime, getLocalTime, getLocalTime, getLong, getLong, getNumber, getNumber, getObj, getShort, getShort, getSqlTime, getSqlTime, getSqlTimestamp, getSqlTimestamp, getStr, getStrpublic static final int DEFAULT_CAPACITY
public JSONArray()
ArrayList 实现public JSONArray(int initialCapacity)
ArrayList 实现initialCapacity - 初始大小public JSONArray(JSONConfig config)
ArrayList 实现config - JSON配置项public JSONArray(int initialCapacity,
JSONConfig config)
ArrayList 实现initialCapacity - 初始大小config - JSON配置项public JSONArray(int initialCapacity,
JSONFactory factory)
ArrayList 实现initialCapacity - 初始大小factory - JSON工厂public JSONFactory getFactory()
JSONgetFactory in interface JSONgetFactory in interface JSONGetter<Integer>public JSON getJSON(Integer key)
JSONGettergetJSON in interface JSONGetter<Integer>key - KEYpublic JSONArray addNull()
null元素,如果设置中忽略null值,则忽略public JSONArray addValue(Boolean value)
ListWrapper.add(Object)value - Number值public JSONArray addValue(Number value)
ListWrapper.add(Object)value - Number值public JSONArray addValue(Character value)
ListWrapper.add(Object)value - Character值public JSONArray addValue(String value)
ListWrapper.add(Object)value - String值public JSONArray addValue(Object value)
ListWrapper.add(Object)value - 值,可以是: Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the null。public JSONObject toJSONObject(JSONArray names) throws JSONException
names - 名列表,位置与JSONArray中的值位置对应JSONException - 如果任何一个名为nullpublic boolean addAll(int index,
Collection<? extends JSON> c)
public JSONArray setValue(int index, Object element)
index - 位置element - 值对象. 可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL.public JSON set(int index, JSON element)
public boolean add(JSON element)
add in interface Collection<JSON>add in interface List<JSON>add in class ListWrapper<JSON>public void add(int index,
JSON element)
public <T> T[] toArray(T[] a)
toArray in interface Collection<JSON>toArray in interface List<JSON>toArray in class ListWrapper<JSON>public Object toArray(Class<?> arrayClass)
arrayClass - 数组元素类型public <T> List<T> toList(Class<T> elementType)
T - 元素类型elementType - 元素类型ArrayListpublic String toString()
public void write(JSONWriter writer) throws JSONException
JSONwrite in interface JSONwriter - writerJSONException - JSON相关异常Copyright © 2025. All rights reserved.