BaseItem, EntityListJsonArrayLazypublic class JsonArray extends SortedList<java.lang.Object> implements EntityList
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.| Modifier and Type | Field | Description |
|---|---|---|
static char |
END |
|
static char |
START |
ALLOWDUPLICATE, ALLOWEMPTYVALUE, BIDI, CASESENSITIVE, flag, MAP, READONLY, REMOVED, VISIBLEPROPERTYcpr| Constructor | Description |
|---|---|
JsonArray() |
Default Constructor
|
| Modifier and Type | Method | Description |
|---|---|---|
static JsonArray |
create(java.lang.String value) |
|
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.
|
protected java.lang.String |
parseItem(EntityStringConverter converter) |
Make a prettyprinted JSON text of this JSONArray.
|
boolean |
remove(java.lang.Object value) |
|
int |
sizeChildren() |
|
JsonArray |
subList(int fromIndex,
int toIndex) |
Returns a view of the portion of this list between the specified
fromIndex, inclusive, and toIndex, exclusive.
|
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.
|
JsonArray |
withValue(Buffer values) |
Set the value to Tokener or pairs of values
|
JsonArray |
withValue(BaseItem... values) |
JSONArray from a BaseEntityArray.
|
JsonArray |
withValue(Tokener x) |
JSONArray from a JSONTokener.
|
JsonArray |
withValue(java.lang.String value) |
JSONArray from a source JSON text.
|
add, addHashItem, addKeyValue, checkValue, clear, contains, containsAll, containsAll, first, flag, get, getByIndex, getKeyByIndex, getPositionKey, getTypClass, getValue, hashKey, hasKeyAndPos, indexOf, init, init, init, isAllowDuplicate, isAllowEmptyValue, isCaseSensitive, isEmpty, isReadOnly, isVisible, last, lastIndexOf, move, pack, removeAll, removeByIndex, removeByObject, removeItem, replaceAllValues, reset, reset, retainAll, setAllowEmptyValue, setFlag, setValue, size, toArray, toArray, toString, with, withAllowDuplicate, withAllowEmptyValue, withCaseSensitive, withFlag, without, withSize, withType, withVisibleadd, addAll, addAll, ceiling, copyEntity, equals, filter, filterItems, hashCode, iterator, iterator, iteratorReverse, listIterator, listIterator, lower, remove, set, subSet, withListcomparator, getChild, isComparator, toStringadd, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, toArray, toArrayfinalize, getClass, notify, notifyAll, wait, wait, waitadd, clone, fireProperty, withListenercomparator, getChild, headSet, higher, isComparator, tailSet, toString, withComparator, withComparatorpublic static final char START
public static final char END
public JsonArray getJSONArray(int index)
index - The index must be between 0 and length() - 1.public int sizeChildren()
sizeChildren in interface EntityListpublic 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.
toString in interface BaseItemtoString in class AbstractArray<java.lang.Object>protected java.lang.String parseItem(EntityStringConverter converter)
parseItem in class AbstractArray<java.lang.Object>converter - Factor for spacing between Levelpublic 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(Buffer values)
withValue in interface EntityListvalues - a simple String of Value or pairs of key-valuespublic 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 class SimpleList<java.lang.Object>public JsonArray subList(int fromIndex, int toIndex)
AbstractArraysubList in class SimpleList<java.lang.Object>fromIndex - low endpoint (inclusive) of the subListtoIndex - high endpoint (exclusive) of the subListpublic static JsonArray create(java.lang.String value)