JSON_ ARRAY_ LENGTH
fun JSON_ARRAY_LENGTH(json: KQLiteColumn<out KQLiteJson?>, path: String? = null): KQLiteColumn<Int?>
Returns the number of elements in a JSON array.
If a path is provided, it returns the length of the array at that path within the JSON. If the json argument is not a well-formed JSON array (or the value at the specified path is not a JSON array), this function returns NULL.
Example:
val jsonCol = jsonColumn("json_data") // Contains '{"a":[1,2,3]}'
// SELECT JSON_ARRAY_LENGTH(json_data, '$.a')
// Result: 3
select(JSON_ARRAY_LENGTH(jsonCol, "$.a")).from(MyTable).execute()
// Example with a JSON array literal
// SELECT JSON_ARRAY_LENGTH(JSON('[10, 20]'))
// Result: 2
select(JSON_ARRAY_LENGTH(JSON("[10, 20]"))).execute()Content copied to clipboard
Return
A KQLiteColumn of type Int representing the number of elements in the array, or NULL on error.
Author
MOHAMMAD AZIM ANSARI
Parameters
json
The KQLiteJson column to analyze.
path
An optional path to a specific array within the JSON structure. If null, the top-level JSON value is used.