public class JSONArray
extends java.util.ArrayList<java.lang.Object>
| Modifier and Type | Field and Description |
|---|---|
(package private) static ObjectWriter<JSONArray> |
arrayWriter |
private static long |
serialVersionUID |
| Constructor and Description |
|---|
JSONArray()
default
|
JSONArray(java.util.Collection<?> collection) |
JSONArray(int initialCapacity) |
JSONArray(java.lang.Object... items) |
| Modifier and Type | Method and Description |
|---|---|
JSONArray |
addArray()
|
JSONObject |
addObject()
Adds a new
JSONObject to the end of this JSONArray. |
java.lang.Object |
clone()
Creates and returns a copy of this
JSONArray. |
static JSONArray |
copyOf(java.util.Collection collection)
Returns an
JSONArray containing the elements of the given Collection, in its iteration order. |
JSONArray |
fluentAdd(java.lang.Object element)
Chained addition of elements
|
JSONArray |
fluentAddAll(java.util.Collection<?> c)
Chained add operation that appends all of the elements in the specified collection to the end of this list.
|
JSONArray |
fluentClear()
Chained clear operation that removes all elements from this
JSONArray. |
JSONArray |
fluentRemove(int index)
Chained remove operation that removes the element at the specified position.
|
JSONArray |
fluentRemove(java.lang.Object o)
Chained remove operation that removes the first occurrence of the specified element.
|
JSONArray |
fluentRemoveAll(java.util.Collection<?> c)
Chained remove operation that removes from this list all of its elements that are contained in the specified collection.
|
JSONArray |
fluentSet(int index,
java.lang.Object element)
Chained set operation that replaces the element at the specified position.
|
static JSONArray |
from(java.lang.Object obj)
See
JSON.toJSON(java.lang.Object) for details |
static JSONArray |
from(java.lang.Object obj,
JSONWriter.Feature... writeFeatures)
See
JSON.toJSON(java.lang.Object) for details |
java.math.BigDecimal |
getBigDecimal(int index)
Returns the
BigDecimal at the specified location in this JSONArray. |
java.math.BigInteger |
getBigInteger(int index)
Returns the
BigInteger at the specified location in this JSONArray. |
java.lang.Boolean |
getBoolean(int index)
Returns the
Boolean at the specified location in this JSONArray. |
boolean |
getBooleanValue(int index)
Returns a boolean value at the specified location in this
JSONArray. |
java.lang.Byte |
getByte(int index)
Returns the
Byte at the specified location in this JSONArray. |
byte |
getByteValue(int index)
Returns a byte value at the specified location in this
JSONArray. |
java.util.Date |
getDate(int index)
Returns the
Date at the specified location in this JSONArray. |
java.util.Date |
getDate(int index,
java.util.Date defaultValue)
Returns the
Date at the specified location in this JSONArray. |
java.lang.Double |
getDouble(int index)
Returns the
Double at the specified location in this JSONArray. |
double |
getDoubleValue(int index)
Returns a double value at the specified location in this
JSONArray. |
java.lang.Float |
getFloat(int index)
Returns the
Float at the specified location in this JSONArray. |
float |
getFloatValue(int index)
Returns a float value at the specified location in this
JSONArray. |
java.time.Instant |
getInstant(int index)
Returns the
Instant at the specified location in this JSONArray. |
java.lang.Integer |
getInteger(int index)
Returns the
Integer at the specified location in this JSONArray. |
int |
getIntValue(int index)
Returns an int value at the specified location in this
JSONArray. |
JSONArray |
getJSONArray(int index)
|
JSONObject |
getJSONObject(int index)
Returns the
JSONObject at the specified location in this JSONArray. |
java.time.LocalDate |
getLocalDate(int index)
Returns the
LocalDate at the specified location in this JSONArray. |
java.time.LocalDate |
getLocalDate(int index,
java.time.LocalDate defaultValue)
Returns the
LocalDate at the specified location in this JSONArray. |
java.time.LocalDateTime |
getLocalDateTime(int index)
Returns the
LocalDateTime at the specified location in this JSONArray. |
java.time.LocalDateTime |
getLocalDateTime(int index,
java.time.LocalDateTime defaultValue)
Returns the
LocalDateTime at the specified location in this JSONArray. |
java.time.LocalTime |
getLocalTime(int index)
Returns the
LocalTime at the specified location in this JSONArray. |
java.time.LocalTime |
getLocalTime(int index,
java.time.LocalTime defaultValue)
Returns the
LocalTime at the specified location in this JSONArray. |
java.lang.Long |
getLong(int index)
Returns the
Long at the specified location in this JSONArray. |
long |
getLongValue(int index)
Returns a long value at the specified location in this
JSONArray. |
<T> T |
getObject(int index,
java.lang.Class<T> type,
JSONReader.Feature... features)
Returns the result of the
Type converter conversion of the element at the specified position in this JSONArray. |
<T> T |
getObject(int index,
java.util.function.Function<JSONObject,T> creator) |
<T> T |
getObject(int index,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Returns the result of the
Type converter conversion of the element at the specified position in this JSONArray. |
java.time.OffsetDateTime |
getOffsetDateTime(int index)
Returns the
OffsetDateTime at the specified location in this JSONArray. |
java.time.OffsetDateTime |
getOffsetDateTime(int index,
java.time.OffsetDateTime defaultValue)
Returns the
OffsetDateTime at the specified location in this JSONArray. |
java.time.OffsetTime |
getOffsetTime(int index)
Returns the
OffsetTime at the specified location in this JSONArray. |
java.time.OffsetTime |
getOffsetTime(int index,
java.time.OffsetTime defaultValue)
Returns the
OffsetTime at the specified location in this JSONArray. |
java.lang.Short |
getShort(int index)
Returns the
Short at the specified location in this JSONArray. |
short |
getShortValue(int index)
Returns a short value at the specified location in this
JSONArray. |
java.lang.String |
getString(int index)
Returns the
String at the specified location in this JSONArray. |
java.lang.String |
getString(int index,
java.lang.String defaultValue)
Returns the
String at the specified location in this JSONArray. |
java.time.ZonedDateTime |
getZonedDateTime(int index)
Returns the
ZonedDateTime at the specified location in this JSONArray. |
java.time.ZonedDateTime |
getZonedDateTime(int index,
java.time.ZonedDateTime defaultValue)
Returns the
ZonedDateTime at the specified location in this JSONArray. |
boolean |
isValid(JSONSchema schema)
Checks if this
JSONArray is valid against the specified JSONSchema. |
static JSONArray |
of(java.lang.Object... items)
Pack multiple elements as
JSONArray |
static JSONArray |
of(java.lang.Object item)
Pack an element as
JSONArray |
static JSONArray |
of(java.lang.Object first,
java.lang.Object second)
Pack two elements as
JSONArray |
static JSONArray |
of(java.lang.Object first,
java.lang.Object second,
java.lang.Object third)
Pack three elements as
JSONArray |
static JSONArray |
parse(java.lang.String text,
JSONReader.Feature... features)
Parse JSON
String into JSONArray |
static <T> java.util.List<T> |
parseArray(java.lang.String input,
java.lang.Class<T> type)
Parse JSON
String into List |
static <T> java.util.List<T> |
parseArray(java.lang.String text,
java.lang.Class<T> type,
JSONReader.Feature... features)
Parse JSON
String into List |
static JSONArray |
parseArray(java.lang.String text,
JSONReader.Feature... features)
Parse JSON
String into JSONArray |
java.lang.Object |
set(int index,
java.lang.Object element)
Replaces the element at the specified position with the specified element
|
<T> T |
to(java.lang.Class<T> type) |
<T> T |
to(java.lang.reflect.Type type)
Convert this
JSONArray to the specified Object |
<T> T |
to(java.lang.reflect.Type type,
long features)
Convert this
JSONArray to the specified Object |
<T> T[] |
toArray(java.lang.Class<T> itemClass,
JSONReader.Feature... features)
Convert all the members of this
JSONArray into the specified Object. |
<T> java.util.List<T> |
toJavaList(java.lang.Class<T> clazz,
JSONReader.Feature... features)
Convert all the members of this
JSONArray into the specified Object. |
<T> T |
toJavaObject(java.lang.reflect.Type type)
Deprecated.
since 2.0.4, please use
to(Type) |
byte[] |
toJSONBBytes(JSONWriter.Feature... features)
Serialize to JSONB bytes
|
java.lang.String |
toJSONString(JSONWriter.Feature... features)
Serialize to JSON
String |
static java.lang.String |
toJSONString(java.lang.Object object,
JSONWriter.Feature... features)
Serialize Java Object to JSON
String with specified JSONReader.Features enabled |
<T> java.util.List<T> |
toList(java.lang.Class<T> itemClass,
JSONReader.Feature... features)
Convert all the members of this
JSONArray into the specified Object. |
java.lang.String |
toString()
Serialize to JSON
String |
java.lang.String |
toString(JSONWriter.Feature... features)
Serialize to JSON
String |
add, add, addAll, addAll, clear, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, size, sort, spliterator, subList, toArray, toArray, trimToSizeprivate static final long serialVersionUID
static ObjectWriter<JSONArray> arrayWriter
public JSONArray()
public JSONArray(int initialCapacity)
initialCapacity - the initial capacity of the JSONArrayjava.lang.IllegalArgumentException - If the specified initial capacity is negativepublic JSONArray(java.util.Collection<?> collection)
collection - the collection whose elements are to be placed into this JSONArrayjava.lang.NullPointerException - If the specified collection is nullpublic JSONArray(java.lang.Object... items)
items - the array whose elements are to be placed into this JSONArrayjava.lang.NullPointerException - If the specified items is nullpublic java.lang.Object set(int index,
java.lang.Object element)
JSONArray array = new JSONArray();
array.add(-1); // [-1]
array.add(2); // [-1,2]
array.set(0, 1); // [1,2]
array.set(4, 3); // [1,2,null,null,3]
array.set(-1, -1); // [1,2,null,null,-1]
array.set(-2, -2); // [1,2,null,-2,-1]
array.set(-6, -6); // [-6,1,2,null,-2,-1]
set in interface java.util.List<java.lang.Object>set in class java.util.ArrayList<java.lang.Object>index - index of the element to replaceelement - element to be stored at the specified positionpublic JSONArray getJSONArray(int index)
index - index of the element to returnJSONArray or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public JSONObject getJSONObject(int index)
JSONObject at the specified location in this JSONArray.index - index of the element to returnJSONObject or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.lang.String getString(int index)
String at the specified location in this JSONArray.index - index of the element to returnString or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.lang.String getString(int index,
java.lang.String defaultValue)
String at the specified location in this JSONArray.index - index of the element to returndefaultValue - the default mapping of the indexString or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.lang.Double getDouble(int index)
Double at the specified location in this JSONArray.index - index of the element to returnDouble or nulljava.lang.NumberFormatException - If the value of get is String and it contains no parsable doubleJSONException - Unsupported type conversion to Doublejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public double getDoubleValue(int index)
JSONArray.index - index of the element to returnjava.lang.NumberFormatException - If the value of get is String and it contains no parsable doubleJSONException - Unsupported type conversion to double valuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.lang.Float getFloat(int index)
Float at the specified location in this JSONArray.index - index of the element to returnFloat or nulljava.lang.NumberFormatException - If the value of get is String and it contains no parsable floatJSONException - Unsupported type conversion to Floatjava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public float getFloatValue(int index)
JSONArray.index - index of the element to returnjava.lang.NumberFormatException - If the value of get is String and it contains no parsable floatJSONException - Unsupported type conversion to float valuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.lang.Long getLong(int index)
Long at the specified location in this JSONArray.index - index of the element to returnLong or nulljava.lang.NumberFormatException - If the value of get is String and it contains no parsable longJSONException - Unsupported type conversion to Longjava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public long getLongValue(int index)
JSONArray.index - index of the element to returnjava.lang.NumberFormatException - If the value of get is String and it contains no parsable longJSONException - Unsupported type conversion to long valuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.lang.Integer getInteger(int index)
Integer at the specified location in this JSONArray.index - index of the element to returnInteger or nulljava.lang.NumberFormatException - If the value of get is String and it contains no parsable intJSONException - Unsupported type conversion to Integerjava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public int getIntValue(int index)
JSONArray.index - index of the element to returnjava.lang.NumberFormatException - If the value of get is String and it contains no parsable intJSONException - Unsupported type conversion to int valuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.lang.Short getShort(int index)
Short at the specified location in this JSONArray.index - index of the element to returnShort or nulljava.lang.NumberFormatException - If the value of get is String and it contains no parsable shortJSONException - Unsupported type conversion to Shortjava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public short getShortValue(int index)
JSONArray.index - index of the element to returnjava.lang.NumberFormatException - If the value of get is String and it contains no parsable shortJSONException - Unsupported type conversion to short valuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.lang.Byte getByte(int index)
Byte at the specified location in this JSONArray.index - index of the element to returnByte or nulljava.lang.NumberFormatException - If the value of get is String and it contains no parsable byteJSONException - Unsupported type conversion to Bytejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public byte getByteValue(int index)
JSONArray.index - index of the element to returnjava.lang.NumberFormatException - If the value of get is String and it contains no parsable byteJSONException - Unsupported type conversion to byte valuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.lang.Boolean getBoolean(int index)
Boolean at the specified location in this JSONArray.index - index of the element to returnBoolean or nullJSONException - Unsupported type conversion to Booleanjava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public boolean getBooleanValue(int index)
JSONArray.index - index of the element to returnJSONException - Unsupported type conversion to boolean valuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.math.BigInteger getBigInteger(int index)
BigInteger at the specified location in this JSONArray.index - index of the element to returnBigInteger or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())JSONException - Unsupported type conversion to BigIntegerjava.lang.NumberFormatException - If the value of get is String and it is not a valid representation of BigIntegerpublic java.math.BigDecimal getBigDecimal(int index)
BigDecimal at the specified location in this JSONArray.index - index of the element to returnBigDecimal or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())JSONException - Unsupported type conversion to BigDecimaljava.lang.NumberFormatException - If the value of get is String and it is not a valid representation of BigDecimalpublic java.util.Date getDate(int index)
Date at the specified location in this JSONArray.index - index of the element to returnDate or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.util.Date getDate(int index,
java.util.Date defaultValue)
Date at the specified location in this JSONArray.index - index of the element to returndefaultValue - default value to return if the element is nullDate or defaultValuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.Instant getInstant(int index)
Instant at the specified location in this JSONArray.index - index of the element to returnInstant or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.LocalDate getLocalDate(int index)
LocalDate at the specified location in this JSONArray.index - index of the element to returnLocalDate or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.LocalDate getLocalDate(int index,
java.time.LocalDate defaultValue)
LocalDate at the specified location in this JSONArray.index - index of the element to returndefaultValue - default value to return if the element is nullLocalDate or defaultValuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.LocalTime getLocalTime(int index)
LocalTime at the specified location in this JSONArray.index - index of the element to returnLocalTime or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.LocalTime getLocalTime(int index,
java.time.LocalTime defaultValue)
LocalTime at the specified location in this JSONArray.index - index of the element to returndefaultValue - default value to return if the element is nullLocalTime or defaultValuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.OffsetTime getOffsetTime(int index)
OffsetTime at the specified location in this JSONArray.index - index of the element to returnOffsetTime or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.OffsetTime getOffsetTime(int index,
java.time.OffsetTime defaultValue)
OffsetTime at the specified location in this JSONArray.index - index of the element to returndefaultValue - default value to return if the element is nullOffsetTime or defaultValuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.LocalDateTime getLocalDateTime(int index)
LocalDateTime at the specified location in this JSONArray.index - index of the element to returnLocalDateTime or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.LocalDateTime getLocalDateTime(int index,
java.time.LocalDateTime defaultValue)
LocalDateTime at the specified location in this JSONArray.index - index of the element to returndefaultValue - default value to return if the element is nullLocalDateTime or defaultValuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.OffsetDateTime getOffsetDateTime(int index)
OffsetDateTime at the specified location in this JSONArray.index - index of the element to returnOffsetDateTime or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.OffsetDateTime getOffsetDateTime(int index,
java.time.OffsetDateTime defaultValue)
OffsetDateTime at the specified location in this JSONArray.index - index of the element to returndefaultValue - default value to return if the element is nullOffsetDateTime or defaultValuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.ZonedDateTime getZonedDateTime(int index)
ZonedDateTime at the specified location in this JSONArray.index - index of the element to returnZonedDateTime or nulljava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.time.ZonedDateTime getZonedDateTime(int index,
java.time.ZonedDateTime defaultValue)
ZonedDateTime at the specified location in this JSONArray.index - index of the element to returndefaultValue - default value to return if the element is nullZonedDateTime or defaultValuejava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public java.lang.String toString()
StringtoString in class java.util.AbstractCollection<java.lang.Object>Stringpublic java.lang.String toString(JSONWriter.Feature... features)
Stringfeatures - features to be enabled in serializationStringpublic java.lang.String toJSONString(JSONWriter.Feature... features)
Stringfeatures - features to be enabled in serializationStringpublic static java.lang.String toJSONString(java.lang.Object object,
JSONWriter.Feature... features)
String with specified JSONReader.Features enabledobject - Java Object to be serialized into JSON Stringfeatures - features to be enabled in serializationpublic byte[] toJSONBBytes(JSONWriter.Feature... features)
features - features to be enabled in serializationpublic <T> T to(java.lang.reflect.Type type)
JSONArray to the specified Object
JSONArray array = ...
List<User> users = array.to(new TypeReference<ArrayList<User>>(){}.getType());
type - specify the Type to be convertedpublic <T> T to(java.lang.reflect.Type type,
long features)
JSONArray to the specified Object
JSONArray array = ...
List<User> users = array.to(new TypeReference<ArrayList<User>>(){}.getType());
type - specify the Type to be convertedpublic <T> T to(java.lang.Class<T> type)
@Deprecated public <T> T toJavaObject(java.lang.reflect.Type type)
to(Type)JSONArray to the specified Objecttype - specify the Type to be convertedpublic <T> java.util.List<T> toList(java.lang.Class<T> itemClass,
JSONReader.Feature... features)
JSONArray into the specified Object.
String json = "[{\"id\": 1, \"name\": \"fastjson\"}, {\"id\": 2, \"name\": \"fastjson2\"}]";
JSONArray array = JSON.parseArray(json);
List<User> users = array.toList(User.class);
itemClass - specify the Class<T> to be convertedfeatures - features to be enabled in parsingpublic <T> T[] toArray(java.lang.Class<T> itemClass,
JSONReader.Feature... features)
JSONArray into the specified Object.
String json = "[{\"id\": 1, \"name\": \"fastjson\"}, {\"id\": 2, \"name\": \"fastjson2\"}]";
JSONArray array = JSON.parseArray(json);
List<User> users = array.toList(User.class);
itemClass - specify the Class<T> to be convertedfeatures - features to be enabled in parsingpublic <T> java.util.List<T> toJavaList(java.lang.Class<T> clazz,
JSONReader.Feature... features)
JSONArray into the specified Object.clazz - specify the Class<T> to be convertedfeatures - features to be enabled in parsing
please use toList(Class, JSONReader.Feature...)public <T> T getObject(int index,
java.lang.reflect.Type type,
JSONReader.Feature... features)
Type converter conversion of the element at the specified position in this JSONArray.
JSONArray array = ...
User user = array.getObject(0, TypeReference<HashMap<String ,User>>(){}.getType());
index - index of the element to returntype - specify the Type to be converted<T> or nullJSONException - If no suitable conversion method is foundjava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public <T> T getObject(int index,
java.lang.Class<T> type,
JSONReader.Feature... features)
Type converter conversion of the element at the specified position in this JSONArray.
User user = jsonArray.getObject(0, User.class);
index - index of the element to returntype - specify the Class to be converted<T> or nullJSONException - If no suitable conversion method is foundjava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size())public <T> T getObject(int index,
java.util.function.Function<JSONObject,T> creator)
public JSONObject addObject()
JSONObject to the end of this JSONArray.JSONObjectpublic JSONArray fluentAdd(java.lang.Object element)
JSONArray array = new JSONArray().fluentAdd(1).fluentAdd(2).fluentAdd(3);
element - element to be appended to this listJSONArray instancepublic JSONArray fluentClear()
JSONArray.JSONArray instancepublic JSONArray fluentRemove(int index)
index - the index of the element to be removedJSONArray instancepublic JSONArray fluentSet(int index, java.lang.Object element)
index - index of the element to replaceelement - element to be stored at the specified positionJSONArray instancepublic JSONArray fluentRemove(java.lang.Object o)
o - element to be removed from this list, if presentJSONArray instancepublic JSONArray fluentRemoveAll(java.util.Collection<?> c)
c - collection containing elements to be removed from this listJSONArray instancepublic JSONArray fluentAddAll(java.util.Collection<?> c)
c - collection containing elements to be added to this listJSONArray instancepublic boolean isValid(JSONSchema schema)
JSONArray is valid against the specified JSONSchema.schema - the JSONSchema to validate againstJSONArray is valid against the schema, false otherwisepublic java.lang.Object clone()
JSONArray.clone in class java.util.ArrayList<java.lang.Object>public static JSONArray of(java.lang.Object... items)
JSONArray
JSONArray array = JSONArray.of(1, 2, "3", 4F, 5L, 6D, true);
items - element setpublic static JSONArray of(java.lang.Object item)
JSONArray
JSONArray array = JSONArray.of("fastjson");
item - target elementpublic static JSONArray copyOf(java.util.Collection collection)
JSONArray containing the elements of the given Collection, in its iteration order.
JSONArray array = JSONArray.copyOf(List.of("fastjson"));
public static JSONArray of(java.lang.Object first, java.lang.Object second)
JSONArray
JSONArray array = JSONArray.of("fastjson", 2);
first - first elementsecond - second elementpublic static JSONArray of(java.lang.Object first, java.lang.Object second, java.lang.Object third)
JSONArray
JSONArray array = JSONArray.of("fastjson", 2, true);
first - first elementsecond - second elementthird - third elementpublic static JSONArray parseArray(java.lang.String text, JSONReader.Feature... features)
String into JSONArraytext - the JSON String to be parsedfeatures - features to be enabled in parsingpublic static <T> java.util.List<T> parseArray(java.lang.String text,
java.lang.Class<T> type,
JSONReader.Feature... features)
String into Listtext - the JSON String to be parsedtype - specify the Class to be convertedfeatures - features to be enabled in parsingpublic static JSONArray parse(java.lang.String text, JSONReader.Feature... features)
String into JSONArraytext - the JSON String to be parsedfeatures - features to be enabled in parsingpublic static <T> java.util.List<T> parseArray(java.lang.String input,
java.lang.Class<T> type)
String into Listinput - the JSON String to be parsedtype - specify the Class to be convertedpublic static JSONArray from(java.lang.Object obj)
JSON.toJSON(java.lang.Object) for detailspublic static JSONArray from(java.lang.Object obj, JSONWriter.Feature... writeFeatures)
JSON.toJSON(java.lang.Object) for details