JSON_ QUOTE
Converts a SQL value into a JSON value.
This function takes a single SQL value (which can be a number, a string, a BLOB, or NULL) and returns its JSON representation as a string.
A numeric value is converted to a JSON number.
NULLis converted to the JSONnullliteral.A
BLOBvalue is interpreted as a UTF-8 string and then converted to a JSON string.A text string is converted to a JSON string, with special characters properly escaped.
This is useful for safely embedding values into a larger JSON structure.
Example:
// Convert a number to a JSON number
// SELECT JSON_QUOTE(123)
// Result: '123'
select(JSON_QUOTE(123)).execute()
// Convert a string to a JSON string (with quotes and escaping)
// SELECT JSON_QUOTE('hello "world"')
// Result: '"hello \"world\""'
select(JSON_QUOTE("hello \"world\"")).execute()
// Convert a column value
val nameCol = textColumn("name") // e.g., contains 'O'Brien'
// SELECT JSON_QUOTE(name) FROM MyTable
// Result for 'O'Brien': '"O''Brien"' (SQLite escapes ' with '')
select(JSON_QUOTE(nameCol)).from(MyTable).execute()Content copied to clipboard
Return
A KQLiteColumn of type String containing the JSON representation of the input value.
Author
MOHAMMAD AZIM ANSARI
Parameters
value
The value to be converted into a JSON string. This can be a literal value (e.g., a Number, String) or a KQLiteColumn.