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() }): JSONArray

Get a JSONArray associated with requested key.

Link copied to clipboard
fun getBoolean(k: String, orElse: () -> Boolean = { throw NullPointerException() }): Boolean

Get a Boolean associated with requested key.

Link copied to clipboard
fun getNumber(k: String, orElse: () -> JSONNumber = { throw NullPointerException() }): JSONNumber

Get a JSONNumber associated with requested key.

Link copied to clipboard
fun getObject(k: String, orElse: () -> JSONObject = { throw NullPointerException() }): JSONObject

Get a JSONObject associated with requested key.

Link copied to clipboard
fun getString(k: String, orElse: () -> String = { throw NullPointerException() }): String

Get a String associated with requested key.

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.