json Array Column
Defines a nullable JSON ARRAY column to store a JSON array.
This function creates and registers a column that specifically stores JSON arrays as a JSON ARRAY string. KQLite handles the conversion between the raw JSON string in the database and the KQLiteJsonArray wrapper class. This provides a type-safe way to work with list-like JSON data.
For storing JSON objects, use jsonObjectColumn. For generic JSON of any type (object, array, string, etc.), use jsonColumn.
Example:
object UserData : KQLiteTable("user_data") {
val userId = longColumn("id").primaryKey()
// A nullable JSON ARRAY column to store a list of tags as a JSON array
val tags = jsonArrayColumn("tags")
// A non-null column with a default empty JSON array
val roles = jsonArrayColumn("roles").notNull().default(JsonArrayLiteral("[]"))
}
// Inserting data
UserData
.insert()
.bind {
it.tags.bind(JSON_ARRAY("admin", "editor"))
}.execute()Content copied to clipboard
Return
A KQLiteColumn instance representing the JSON array column, which can be further chained with constraints like notNull(), default(), etc.
Author
MOHAMMAD AZIM ANSARI
Parameters
name
The name of the column in the database.