KQLite Json
interface KQLiteJson
Represents com.kqlite.functions.JSON data stored within a KQLiteTable.jsonColumn.
This interface provides a standardized way to interact with JSON columns, using com.kqlite.functions.JSON functions. It allows storing JSON Object (com.kqlite.functions.JSON_OBJECT) as well as JSON Array (com.kqlite.functions.JSON_ARRAY). This type can be created using KQLiteTable.jsonColumn
Example
object MyTable : KQLiteTable("my_table") {
val data = jsonColumn("data") // Allows any valid JSON
}
// INSERT
MyTable.quickInsert {
// Inserting JSON Object
it.data.bind(JSON("""{"name": "John Doe", "age": 30}"""))
// Inserting JSON Array allowed
// it.data.bind(JSON_ARRAY("tag1", "tag2"))
}
// SELECT
val jsonData: KQLiteJson? = cursor[MyTable.data]
val jsonString = jsonData?.getText()
// Now 'jsonString' can be parsed with libraries like Gson, kotlinx.serialization, etc.Content copied to clipboard
Author
MOHAMMAD AZIM ANSARI