The Kotlin SDK models all data — beyond the dedicated record types — using kotlinx.serialization JSON types. Read methods return a JsonElement; write methods accept a JsonObject.
Source: surrealdb.kotlin
Import
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.putBuilding values
Construct objects with buildJsonObject.
Example
val data = buildJsonObject {
put("name", "Ada")
put("age", 36)
}Decoding values
Rather than navigating raw JsonElement trees, decode results into your own @Serializable types with .queryAs<T>(), .awaitAs<T>(), or .decode<T>().
Example
val people: List<Person> = client.queryAs("SELECT * FROM person")Note
The SDK does not provide dedicated wrapper classes for datetimes, durations, or geometries. Express these as SurrealQL literals or the JSON values SurrealDB expects, and decode results into your own types.