JSONObject

class JSONObject : JSONData, Iterable<Map.Entry<String, JSONData>>

A JSONObject is produced by a JSONReader when an object is read. Each key of the object is a String and each value is a JSONData.

Author

Todd L Smith

Parameters

map

The field assignments of the JSONObject as a Map from keys to values. 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
fun containsKey(k: String): Boolean

Does the JSONObject include a binding for the specified key?

Link copied to clipboard
open fun forEach(p0: Consumer<in Map.Entry<String, JSONData>>)
Link copied to clipboard
operator fun get(k: String): JSONData

Get a JSONData associated with requested key.

Link copied to clipboard
fun getArray(k: String, orElse: () -> JSONArray = { throw NullPointerException("Key, $k, not found.") }): JSONArray

Get a JSONArray associated with requested key.

Link copied to clipboard
fun getArrayOrNull(k: String): JSONArray?

Get a JSONArray associated with requested key, or null if no such key exists.

Link copied to clipboard
fun getBigDecimal(k: String, orElse: () -> BigDecimal = { throw NullPointerException("Key, $k, not found.") }): BigDecimal

Get a BigDecimal associated with requested key.

Link copied to clipboard
fun getBigDecimalOrNull(k: String): BigDecimal?

Get a BigDecimal associated with requested key, or null if no such key exists.

Link copied to clipboard
fun getBigInteger(k: String, orElse: () -> BigInteger = { throw NullPointerException("Key, $k, not found.") }): BigInteger

Get a BigInteger associated with requested key.

Link copied to clipboard
fun getBigIntegerOrNull(k: String): BigInteger?

Get a BigInteger associated with requested key, or null if no such key exists.

Link copied to clipboard
fun getBoolean(k: String, orElse: () -> Boolean = { throw NullPointerException("Key, $k, not found.") }): Boolean

Get a Boolean associated with requested key.

Link copied to clipboard
fun getBooleanOrNull(k: String): Boolean?

Get a Boolean associated with requested key, or null if no such key exists.

Link copied to clipboard
fun getDouble(k: String, orElse: () -> Double = { throw NullPointerException("Key, $k, not found.") }): Double

Get a Double associated with requested key.

Link copied to clipboard
fun getDoubleOrNull(k: String): Double?

Get a Double associated with requested key, or null if no such key exists.

Link copied to clipboard
fun getFloat(k: String, orElse: () -> Float = { throw NullPointerException("Key, $k, not found.") }): Float

Get a Float associated with requested key.

Link copied to clipboard
fun getFloatOrNull(k: String): Float?

Get a Float associated with requested key, or null if no such key exists.

Link copied to clipboard
fun getInt(k: String, orElse: () -> Int = { throw NullPointerException("Key, $k, not found.") }): Int

Get a Int associated with requested key.

Link copied to clipboard
fun getIntOrNull(k: String): Int?

Get a Int associated with requested key, or null if no such key exists.

Link copied to clipboard
fun getLong(k: String, orElse: () -> Long = { throw NullPointerException("Key, $k, not found.") }): Long

Get a Long associated with requested key.

Link copied to clipboard
fun getLongOrNull(k: String): Long?

Get a Long associated with requested key, or null if no such key exists.

Link copied to clipboard
fun getNumber(k: String, orElse: () -> JSONNumber = { throw NullPointerException("Key, $k, not found.") }): JSONNumber

Get a JSONNumber associated with requested key.

Link copied to clipboard
fun getNumberOrNull(k: String): JSONNumber?

Get a JSONNumber associated with requested key, or null if no such key exists.

Link copied to clipboard
fun getObject(k: String, orElse: () -> JSONObject = { throw NullPointerException("Key, $k, not found.") }): JSONObject

Get a JSONObject associated with requested key.

Link copied to clipboard
fun getObjectOrNull(k: String): JSONObject?

Get a JSONObject associated with requested key, or null if no such key exists.

Link copied to clipboard
fun getString(k: String, orElse: () -> String = { throw NullPointerException("Key, $k, not found.") }): String

Get a String associated with requested key.

Link copied to clipboard
fun getStringOrNull(k: String): String?

Get a String associated with requested key, or null if no such key exists.

Link copied to clipboard
open operator override fun iterator(): Iterator<Map.Entry<String, JSONData>>
Link copied to clipboard
open fun spliterator(): Spliterator<Map.Entry<String, 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
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
open val boolean: Boolean

Extract a Boolean, or throw a ClassCastException if the value 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
open val float: Float

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

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
open 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 override 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
open val string: String

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