public 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.cprALLOWDUPLICATE, ALLOWEMPTYVALUE, BIDI, CASESENSITIVE, flag, MAP, READONLY, REMOVED, VISIBLE| Constructor and Description |
|---|
JsonArray() |
| Modifier and Type | Method and Description |
|---|---|
JsonObject |
get(java.lang.String id) |
SimpleList<EntityList> |
getChildren() |
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) |
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.
|
java.lang.String |
toString(int indentFactor)
Make a prettyprinted JSON text of this JSONArray.
|
JsonArray |
withValue(BaseItem... values)
JSONArray from a BaseEntityArray.
|
JsonArray |
withValue(Buffer values)
Set the value to Tokener or pairs of values
|
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, withComparatorclone, filter, withadd, add, addAll, addAll, ceiling, copyEntity, filterItems, iteratorReverse, listIterator, listIterator, remove, set, subSet, withListaddHashItem, addKeyValue, checkValue, clear, contains, containsAll, fireProperty, first, flag, get, getByIndex, getKeyByIndex, getPositionKey, getValue, hashKey, hasKeyAndPos, indexOf, init, init, init, isAllowDuplicate, isAllowEmptyValue, isCaseSensitive, isEmpty, isReadOnly, isVisible, iterator, last, lastIndexOf, move, pack, removeAll, removeByObject, reset, retainAll, setAllowEmptyValue, setFlag, setValue, size, toArray, toArray, toString, withAllowDuplicate, withAllowEmptyValue, withCaseSensitive, withFlag, without, withSize, withVisibleequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcomparator, isComparator, sizepublic 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.
toString in interface BaseItemtoString in class AbstractArray<java.lang.Object>public java.lang.String toString(int indentFactor)
toString in interface EntityListindentFactor - The number of spaces to add to each level of indentation.[ (left
bracket) and ending with ]
(right bracket).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 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)
AbstractArraysubList in interface java.util.List<java.lang.Object>subList in class SimpleList<java.lang.Object>fromIndex - low endpoint (inclusive) of the subListtoIndex - high endpoint (exclusive) of the subListpublic SimpleList<EntityList> getChildren()
getChildren in interface EntityList