JSONArray

class JSONArray : JSONData, Iterable<JSONData>

A JSONArray is produced by a JSONReader when an array is read. Each element is a JSONData.

Author

Todd L Smith

Parameters

array

The array of JSONDatas. This must not be modified by the caller afterward; this call transfers ownership of the reference.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open fun forEach(p0: Consumer<in JSONData>)
Link copied to clipboard
operator fun get(index: Int): JSONData

Get a JSONData at the requested subscript.

Link copied to clipboard
fun getArray(index: Int, orElse: () -> JSONArray = { throw NullPointerException( "Value at index, $index, was `null` when trying to read an " + "Array.") }): JSONArray

Get a JSONArray at the requested subscript.

Link copied to clipboard
fun getArrayOrNull(index: Int): JSONArray?

Get a JSONArray or null at the requested subscript.

Link copied to clipboard
fun getBigDecimal(index: Int, orElse: () -> BigDecimal = { throw NullPointerException( "Value at index, $index, was `null` when trying to read a " + "BigDecimal.") }): BigDecimal

Get a BigDecimal at the requested subscript.

Link copied to clipboard
fun getBigDecimalOrNull(index: Int): BigDecimal?

Get a BigDecimal or null at the requested subscript.

Link copied to clipboard
fun getBigInteger(index: Int, orElse: () -> BigInteger = { throw NullPointerException( "Value at index, $index, was `null` when trying to read a " + "BigInteger.") }): BigInteger

Get a BigInteger at the requested subscript.

Link copied to clipboard
fun getBigIntegerOrNull(index: Int): BigInteger?

Get a BigInteger or null at the requested subscript.

Link copied to clipboard
fun getBoolean(index: Int, orElse: () -> Boolean = { throw NullPointerException( "Value at index, $index, was `null` when trying to read a " + "boolean.") }): Boolean

Get a Boolean at the requested subscript.

Link copied to clipboard
fun getBooleanOrNull(index: Int): Boolean?

Get a Boolean or null at the requested subscript.

Link copied to clipboard
fun getInt(index: Int, orElse: () -> Int = { throw NullPointerException( "Value at index, $index, was `null` when trying to read an " + "Int.") }): Int

Get a Int at the requested subscript.

Link copied to clipboard
fun getIntOrNull(index: Int): Int?

Get a Int or null at the requested subscript.

Link copied to clipboard
fun getLong(index: Int, orElse: () -> Long = { throw NullPointerException( "Value at index, $index, was `null` when trying to read a " + "Long.") }): Long

Get a Long at the requested subscript.

Link copied to clipboard
fun getLongOrNull(index: Int): Long?

Get a Long or null at the requested subscript.

Link copied to clipboard
fun getNumber(index: Int, orElse: () -> JSONNumber = { throw NullPointerException( "Value at index, $index, was `null` when trying to read a " + "number.") }): JSONNumber

Get a JSONNumber at the requested subscript.

Link copied to clipboard
fun getNumberOrNull(index: Int): JSONNumber?

Get a JSONNumber or null at the requested subscript.

Link copied to clipboard
fun getObject(index: Int, orElse: () -> JSONObject = { throw NullPointerException( "Value at index, $index, was `null` when trying to read an " + "Object.") }): JSONObject

Get a JSONObject at the requested subscript.

Link copied to clipboard
fun getObjectOrNull(index: Int): JSONObject?

Get a JSONObject or null at the requested subscript.

Link copied to clipboard
fun getString(index: Int, orElse: () -> String = { throw NullPointerException( "Value at index, $index, was `null` when trying to read a " + "String.") }): String

Get a String at the requested subscript.

Link copied to clipboard
fun getStringOrNull(index: Int): String?

Get a String or null at the requested subscript.

Link copied to clipboard
open operator override fun iterator(): ListIterator<JSONData>
Link copied to clipboard
fun size(): Int

Answer the length of the receiver.

Link copied to clipboard
open fun spliterator(): Spliterator<JSONData>
Link copied to clipboard
open override fun writeTo(writer: JSONWriter)

Emit a JSON representation of the receiver onto the specified writer.

Properties

Link copied to clipboard
open val bigDecimal: BigDecimal

If this is a JSONNumber, extract its value as a BigDecimal, otherwise throw a ClassCastException.

Link copied to clipboard
val bigDecimals: List<BigDecimal>

Extract a List of BigDecimal, throwing a ClassCastException if any elements are non-numeric.

Link copied to clipboard
open val bigInteger: BigInteger

If this is a JSONNumber, extract its value as a BigInteger, otherwise throw a ClassCastException. If the value has a non-zero fractional part, throw an ArithmeticException.

Link copied to clipboard
val bigIntegers: List<BigInteger>

Extract a List of BigInteger, throwing a ClassCastException if any elements are non-numeric, or an ArithmeticException if any elements are non-integral. The first element to fail determines which exception is thrown.

Link copied to clipboard
open val boolean: Boolean

Extract a Boolean, or throw a ClassCastException if the value is not a boolean.

Link copied to clipboard
val booleans: List<Boolean>

Extract a List of Booleans, throwing a ClassCastException if any element is not a boolean.

Link copied to clipboard
open val double: Double

If this is a JSONNumber, extract its value as a Double, otherwise throw a ClassCastException.

Link copied to clipboard
val doubles: List<Double>

Extract a List of Doubles, throwing a ClassCastException if any elements are non-numeric.

Link copied to clipboard
open val float: Float

If this is a JSONNumber, extract its value as a Float, otherwise throw a ClassCastException.

Link copied to clipboard
val floats: List<Float>

Extract a List of Floats, throwing a ClassCastException if any elements are non-numeric.

Link copied to clipboard
open val int: Int

If this is a JSONNumber, extract its value as an Int, otherwise throw a ClassCastException. If the value has a non-zero fractional part or is out of range, throw an ArithmeticException.

Link copied to clipboard
val ints: List<Int>

Extract a List of Ints, throwing a ClassCastException if any elements are non-numeric, or an ArithmeticException if any elements are non-integral or overflow an Int. The first element to fail determines which exception is thrown.

Link copied to clipboard
open override val isArray: Boolean

Is the receiver a JSON?

Link copied to clipboard
open val isBoolean: Boolean

Is the receiver a JSON boolean?

Link copied to clipboard
open val isNull: Boolean

Is the receiver a JSON null?

Link copied to clipboard
open val isNumber: Boolean

Is the receiver a JSON?

Link copied to clipboard
open val isObject: Boolean

Is the receiver a JSON?

Link copied to clipboard
open val isString: Boolean

Is the receiver a JSON string?

Link copied to clipboard
open val long: Long

If this is a JSONNumber, extract its value as a Long, otherwise throw a ClassCastException. If the value has a non-zero fractional part or is out of range, throw an ArithmeticException.

Link copied to clipboard
val longs: List<Long>

Extract a List of Longs, throwing a ClassCastException if any elements are non-numeric, or an ArithmeticException if any elements are non-integral or overflow a Long. The first element to fail determines which exception is thrown.

Link copied to clipboard
open val string: String

Extract a String, or throw a ClassCastException if the value is not a string.

Link copied to clipboard
val strings: List<String>

Extract a List of Strings, throwing a ClassCastException if any element is not a string.