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 UnitappendJSONLinesTo(Appendable a)Append in JSON Lines form 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. UnitoutputTo(IntConsumer out)Output as a JSON string to an IntConsumer. Unitoutput(IntConsumer out)Output as a JSON string to an IntConsumer. final UnitoutputJSONLinesTo(IntConsumer out)Output in JSON Lines form to an IntConsumer. final UnitoutputJSONLines(IntConsumer out)Output in JSON Lines form to an IntConsumer. UnitcoOutputTo(SuspendFunction1<Character, Unit> out)Output as a JSON string to a CoOutput. UnitcoOutput(SuspendFunction1<Character, Unit> out)Output as a JSON string to a CoOutput. final UnitcoOutputJSONLinesTo(SuspendFunction1<Character, Unit> out)Output in JSON lines form to a CoOutput. final UnitcoOutputJSONLines(SuspendFunction1<Character, Unit> out)Output in JSON lines form to a CoOutput. BooleanisEmpty()Return trueif the array is empty.JSONValueget(Integer index)Get the value at the 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.List
contains, containsAll, indexOf, iterator, lastIndexOf, listIterator, listIterator, spliterator -
Methods inherited from class kotlin.collections.Iterable
forEach -
Methods inherited from class kotlin.collections.Collection
parallelStream, stream, toArray -
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.
-
appendJSONLinesTo
final Unit appendJSONLinesTo(Appendable a)
Append in JSON Lines form to an Appendable.
-
appendJSONLines
@Deprecated(message = "renamed to appendJSONLinesTo", replaceWith = @ReplaceWith(imports = {}, expression = "appendJSONLinesTo(a)")) 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.
-
outputTo
Unit outputTo(IntConsumer out)
Output as a JSON string to an IntConsumer.
-
output
@Deprecated(message = "renamed to outputTo", replaceWith = @ReplaceWith(imports = {}, expression = "outputTo(out)")) Unit output(IntConsumer out)
Output as a JSON string to an IntConsumer.
-
outputJSONLinesTo
final Unit outputJSONLinesTo(IntConsumer out)
Output in JSON Lines form to an IntConsumer.
-
outputJSONLines
@Deprecated(message = "renamed to outputJSONLinesTo", replaceWith = @ReplaceWith(imports = {}, expression = "outputJSONLinesTo(out)")) final Unit outputJSONLines(IntConsumer out)
Output in JSON Lines form to an IntConsumer.
-
coOutputTo
Unit coOutputTo(SuspendFunction1<Character, Unit> out)
Output as a JSON string to a CoOutput.
-
coOutput
@Deprecated(message = "renamed to coOutputTo(out)", replaceWith = @ReplaceWith(imports = {}, expression = "coOutputTo(out)")) Unit coOutput(SuspendFunction1<Character, Unit> out)
Output as a JSON string to a CoOutput.
-
coOutputJSONLinesTo
final Unit coOutputJSONLinesTo(SuspendFunction1<Character, Unit> out)
Output in JSON lines form to a CoOutput.
-
coOutputJSONLines
@Deprecated(message = "renamed to coOutputJSONLinesTo", replaceWith = @ReplaceWith(imports = {}, expression = "coOutputJSONLinesTo(out)")) final Unit coOutputJSONLines(SuspendFunction1<Character, Unit> out)
Output in JSON lines form to a CoOutput.
-
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.
-
-
-
-