Class JSONArray
-
- All Implemented Interfaces:
-
io.kjson.JSONStructure,io.kjson.JSONValue,kotlin.collections.Collection,kotlin.collections.Iterable,kotlin.collections.List
public final class JSONArray implements JSONStructure<Int>, List<JSONValue>
A JSON array. As allowed by the JSON specification, array members may be primitive types, objects, other arrays or
null.A
JSONArrayis immutable; instances may be created dynamically using the build function and the Builder class.The
JSONArrayclass implements the Kotlin List interface; all the functions of that interface are available, including indexed access, iteration over the list contents and comparison with another list.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classJSONArray.BuilderJSONArray builder class.
public classJSONArray.Companion
-
Field Summary
Fields Modifier and Type Field Description private final JSONArrayasArrayprivate final JSONArrayasArrayOrNullprivate final Integersizepublic final static JSONArray.CompanionCompanion
-
Method Summary
Modifier and Type Method Description final JSONArraygetAsArray()final JSONArraygetAsArrayOrNull()IntegergetSize()The size of the structure. UnitappendTo(Appendable a)Append as a JSON string to an Appendable. final UnitappendJSONLines(Appendable a)Append in JSON Lines form to an Appendable. StringtoJSON()Convert to a JSON string. final StringtoJSONLines()Convert to a string in JSON Lines form. Unitoutput(IntConsumer out)Output as a JSON string to an IntConsumer. final UnitoutputJSONLines(IntConsumer out)Output in JSON Lines form to an IntConsumer. UnitcoOutput(SuspendFunction1<Character, Unit> out)Output as a JSON string to a CoOutput. final UnitcoOutputJSONLines(SuspendFunction1<Character, Unit> out)Output in JSON lines form to a CoOutput. BooleanisEmpty()Return trueif the array is empty.Booleancontains(JSONValue element)Return trueif the array contains the nominated value.Iterator<JSONValue>iterator()Get an Iteratorover the values in the array.BooleancontainsAll(Collection<JSONValue> elements)Return trueif the array contains all of the values in another collection.JSONValueget(Integer index)Get the value at the given index. IntegerindexOf(JSONValue element)Find the index of the first occurrence of a given value in the array, or -1 if the value is not found. IntegerlastIndexOf(JSONValue element)Find the index of the last occurrence of a given value in the array, or -1 if the value is not found. ListIterator<JSONValue>listIterator()Get a ListIteratorover the values in the array.ListIterator<JSONValue>listIterator(Integer index)Get a ListIteratorover the values in the array, from a given index.JSONArraysubList(Integer fromIndex, Integer toIndex)Get a sub-list of the array. final UnitforEachItem(Function1<JSONValue, Unit> func)Apply a function to each item in the array. final UnitforEachItemIndexed(Function2<Integer, JSONValue, Unit> func)Apply a function to each item in the array, supplying the index. Booleanequals(Object other)Compare the array to another value, applying the rule in Java for comparing Lists.IntegerhashCode()Get the hash code for the array, applying the rule in Java for Listhash codes.StringtoString()Convert to a String (converts to JSON). -
Methods inherited from class io.kjson.JSONStructure
getArray, getBoolean, getByte, getDecimal, getInt, getLong, getObject, getShort, getString, getUByte, getUInt, getULong, getUShort, isNotEmpty -
Methods inherited from class kotlin.collections.Iterable
forEach -
Methods inherited from class kotlin.collections.Collection
parallelStream, stream, toArray -
Methods inherited from class kotlin.collections.List
spliterator -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
getAsArray
final JSONArray getAsArray()
-
getAsArrayOrNull
final JSONArray getAsArrayOrNull()
-
appendTo
Unit appendTo(Appendable a)
Append as a JSON string to an Appendable.
-
appendJSONLines
final Unit appendJSONLines(Appendable a)
Append in JSON Lines form to an Appendable.
-
toJSONLines
final String toJSONLines()
Convert to a string in JSON Lines form.
-
output
Unit output(IntConsumer out)
Output as a JSON string to an IntConsumer.
-
outputJSONLines
final Unit outputJSONLines(IntConsumer out)
Output in JSON Lines form to an IntConsumer.
-
coOutput
Unit coOutput(SuspendFunction1<Character, Unit> out)
Output as a JSON string to a CoOutput.
-
coOutputJSONLines
final Unit coOutputJSONLines(SuspendFunction1<Character, Unit> out)
Output in JSON lines form to a CoOutput.
-
containsAll
Boolean containsAll(Collection<JSONValue> elements)
Return
trueif the array contains all of the values in another collection.
-
indexOf
Integer indexOf(JSONValue element)
Find the index of the first occurrence of a given value in the array, or -1 if the value is not found.
-
lastIndexOf
Integer lastIndexOf(JSONValue element)
Find the index of the last occurrence of a given value in the array, or -1 if the value is not found.
-
listIterator
ListIterator<JSONValue> listIterator()
Get a
ListIteratorover the values in the array.
-
listIterator
ListIterator<JSONValue> listIterator(Integer index)
Get a
ListIteratorover the values in the array, from a given index.
-
forEachItem
final Unit forEachItem(Function1<JSONValue, Unit> func)
Apply a function to each item in the array.
-
forEachItemIndexed
final Unit forEachItemIndexed(Function2<Integer, JSONValue, Unit> func)
Apply a function to each item in the array, supplying the index.
-
equals
Boolean equals(Object other)
Compare the array to another value, applying the rule in Java for comparing
Lists.
-
hashCode
Integer hashCode()
Get the hash code for the array, applying the rule in Java for
Listhash codes.
-
-
-
-