public class JsonArray extends SortedList<java.lang.Object> implements StringItem
get and opt
methods for accessing the values by index, and put methods for
adding or replacing values. The values can be any of these types:
Boolean, JSONArray, JSONObject,
Number, String, or the
JSONObject.NULL object.
The constructor can convert a JSON text into a Java object. The
toString method converts to JSON text.
The generic get() and opt() methods return an
object which you can cast or query for type. There are also typed
get and opt methods that do type checking and type
coercion for you.
The texts produced by the toString methods strictly conform to
JSON syntax rules. The constructors are more forgiving in the texts they will
accept:
, (comma) may appear just
before the closing bracket.null value will be inserted when there is ,
(comma) elision.' (single
quote).{} [ ] / \ : , = ; # and if they do not look like numbers and
if they are not the reserved words true, false, or
null.; (semicolon) as
well as by , (comma).0x- (hex) prefix.cprALLOWDUPLICATE, ALLOWEMPTYVALUE, BIDI, BIG_KEY, BIG_VALUE, CASESENSITIVE, DELETED, elements, emptyArray, flag, MAP, MAXDELETED, MAXUSEDLIST, MINHASHINGSIZE, MINSIZE, MINUSEDLIST, READONLY, SIZE_BIG, SMALL_KEY, SMALL_VALUE, VISIBLE| Constructor and Description |
|---|
JsonArray() |
| Modifier and Type | Method and Description |
|---|---|
JsonObject |
get(java.lang.String id) |
JsonArray |
getJSONArray(int index)
Get the JSONArray associated with an index.
|
JsonObject |
getJSONObject(int index)
Get the JSONObject associated with an index.
|
BaseItem |
getNewList(boolean keyValue)
Get a new Instance of a JsonObject
|
java.lang.String |
getString(int index)
Get the JSONObject associated with an index.
|
boolean |
remove(java.lang.Object value) |
JsonArray |
subList(int fromIndex,
int toIndex) |
JsonObject |
toJSONObject(JsonArray names)
Produce a JSONObject by combining a JSONArray of names with the values of
this JSONArray.
|
java.lang.String |
toString()
Make a JSON text of this JSONArray.
|
java.lang.String |
toString(int indentFactor)
Make a prettyprinted JSON text of this JSONArray.
|
java.lang.String |
toString(int indentFactor,
int indent)
Make a prettyprinted JSON text of this JSONArray.
|
JsonArray |
withValue(BaseItem... values)
JSONArray from a BaseEntityArray.
|
JsonArray |
withValue(java.lang.String value)
JSONArray from a source JSON text.
|
JsonArray |
withValue(Tokener x)
JSONArray from a JSONTokener.
|
comparator, headSet, higher, isComparator, tailSet, withComparator, withComparatorcloneadd, add, addAll, addAll, copyEntity, iteratorReverse, lastIndexOf, listIterator, listIterator, remove, removeItemByObject, set, subSet, with, withAll, withListaddFlag, addHashItem, addKey, addKeyValue, checkValue, clear, contains, containsAll, fireProperty, first, flag, get, getByIndex, getKeyByIndex, getLastPositionKey, getPositionKey, getPositionValue, getSignalFlag, getValueItem, hashKey, hasKey, hasKeyAndPos, indexOf, init, init, init, isAllowDuplicate, isAllowEmptyValue, isCaseSensitive, isEmpty, isReadOnly, isVisible, iterator, last, lastindexOf, move, pack, removeAll, removeByObject, retainAll, setValue, size, toArray, toArray, withAllowDuplicate, withAllowEmptyValue, withCaseSensitive, withFlag, without, withVisibleequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisVisible, withVisiblepublic JsonArray getJSONArray(int index)
index - The index must be between 0 and length() - 1.java.lang.RuntimeException - If there is no value for the index. or if the value is not a
JSONArraypublic JsonObject getJSONObject(int index)
index - subscriptjava.lang.RuntimeException - If there is no value for the index or if the value is not a
JSONObjectpublic java.lang.String getString(int index)
index - subscriptjava.lang.RuntimeException - If there is no value for the index or if the value is not a
JSONObjectpublic JsonObject toJSONObject(JsonArray names)
names - A JSONArray containing a list of key strings. These will be
paired with the values.public java.lang.String toString()
Warning: This method assumes that the data structure is acyclical.
public java.lang.String toString(int indentFactor)
toString in interface StringItemindentFactor - The number of spaces to add to each level of indentation.[ (left
bracket) and ending with ]
(right bracket).public java.lang.String toString(int indentFactor,
int indent)
toString in interface StringItempublic JsonArray withValue(java.lang.String value)
value - A string that begins with [ (left
bracket) and ends with ]
(right bracket).public JsonArray withValue(Tokener x)
x - A JSONTokenerpublic JsonArray withValue(BaseItem... values)
values - of Elements.public JsonObject get(java.lang.String id)
public BaseItem getNewList(boolean keyValue)
getNewList in interface BaseItemgetNewList in class SimpleList<java.lang.Object>public boolean remove(java.lang.Object value)
remove in interface java.util.Collection<java.lang.Object>remove in interface java.util.List<java.lang.Object>remove in class SimpleList<java.lang.Object>public JsonArray subList(int fromIndex, int toIndex)
subList in interface java.util.List<java.lang.Object>subList in class SimpleList<java.lang.Object>