DocumentBuilder

Properties

Link copied to clipboard
val count: Int

The number of the entries in the document.

Link copied to clipboard

A List containing all keys, or an empty List if the document has no properties.

Functions

Link copied to clipboard
operator fun contains(key: String): Boolean

Tests whether a property exists or not. This can be less expensive than getValue(String), because it does not have to allocate an Object for the property value.

Link copied to clipboard

Get a property's value as an Array. Returns null if the property doesn't exist, or its value is not an array.

Link copied to clipboard
fun getBlob(key: String): Blob?

Gets a property's value as a Blob. Returns null if the value doesn't exist, or its value is not a Blob.

Link copied to clipboard

Gets a property's value as a boolean. Returns true if the value exists, and is either true or a nonzero number.

Link copied to clipboard
fun getDate(key: String): Instant?

Gets a property's value as an Instant date. JSON does not directly support dates, so the actual property value must be a string, which is then parsed according to the ISO-8601 date format (the default used in JSON.) Returns null if the value doesn't exist, is not a string, or is not parsable as a date. NOTE: This is not a generic date parser! It only recognizes the ISO-8601 format, with or without milliseconds.

Link copied to clipboard

Get a property's value as a Dictionary. Returns null if the property doesn't exist, or its value is not a dictionary.

Link copied to clipboard

Gets a property's value as a double. Integers will be converted to double. The value true is returned as 1.0, false as 0.0. Returns 0.0 if the property doesn't exist or does not have a numeric value.

Link copied to clipboard
fun getFloat(key: String): Float

Gets a property's value as a float. Integers will be converted to float. The value true is returned as 1.0, false as 0.0. Returns 0.0 if the value doesn't exist or does not have a numeric value.

Link copied to clipboard
fun getInt(key: String): Int

Gets a property's value as an int. Floating point values will be rounded. The value true is returned as 1, false as 0. Returns 0 if the value doesn't exist or does not have a numeric value.

Link copied to clipboard
fun getLong(key: String): Long

Gets a property's value as a long. Floating point values will be rounded. The value true is returned as 1, false as 0. Returns 0 if the value doesn't exist or does not have a numeric value.

Link copied to clipboard
fun getNumber(key: String): Number?

Gets a property's value as a Number. Returns null if the value doesn't exist, or its value is not a Number.

Link copied to clipboard
fun getString(key: String): String?

Gets a property's value as a String. Returns null if the value doesn't exist, or its value is not a String.

Link copied to clipboard
fun getValue(key: String): Any?

Gets a property's value as an object. The object types are Blob, Array, Dictionary, Number, or String based on the underlying data type; or nil if the property value is null or the property doesn't exist.

Link copied to clipboard

Removes the mapping for a key from this Dictionary

Link copied to clipboard
fun setArray(key: String, value: Array?): MutableDocument

Set an Array value for the given key

Link copied to clipboard
fun setBlob(key: String, value: Blob?): MutableDocument

Set a Blob value for the given key

Link copied to clipboard

Set a boolean value for the given key

Link copied to clipboard

Populate a document with content from a Map. Allowed value types are List, Instant, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Arrays, Maps and Dictionaries may contain only the above types. Setting the document content will replace the current data including the existing Array and Dictionary objects.

Link copied to clipboard

Set an Instant date value for the given key

Link copied to clipboard

Set a Dictionary value for the given key

Link copied to clipboard

Set a double value for the given key

Link copied to clipboard

Set a float value for the given key

Link copied to clipboard
fun setInt(key: String, value: Int): MutableDocument

Set an integer value for the given key

Link copied to clipboard

Populate a document with content from a JSON string. Allowed value types are List, Instant, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Arrays, Maps and Dictionaries may contain only the above types. Setting the document content will replace the current data including the existing Array and Dictionary objects.

Link copied to clipboard
fun setLong(key: String, value: Long): MutableDocument

Set a long value for the given key

Link copied to clipboard

Set a Number value for the given key

Link copied to clipboard

Set a String value for the given key

Link copied to clipboard
fun setValue(key: String, value: Any?): MutableDocument

Set an object value by key. Allowed value types are List, Instant, Map, Number, null, String, Array, Blob, and Dictionary. If present, Lists, Arrays, Maps and Dictionaries may contain only the above types. An Instant date object will be converted to an ISO-8601 format string.

Link copied to clipboard
infix fun String.to(value: Any?)

Determines the key-to-value relation between the receiver string and the provided value.

Link copied to clipboard
fun toMap(): Map<String, Any?>

Gets content of the current object as a Map. The values contained in the returned Map object are all JSON based values.