SQLite JSON_ARRAY_LENGTH() Function
Example
Count the items in a JSON array:
SELECT JSON_ARRAY_LENGTH('[1, 2, 3, 4]');
Try it Yourself »
Definition and Usage
The JSON_ARRAY_LENGTH() function returns the number of items in a JSON array. It returns 0 if the value is not an array.
Note: Read more about JSON in the SQLite JSON chapter.
Syntax
JSON_ARRAY_LENGTH(json, path)
Parameter Values
| Parameter | Description |
|---|---|
| json | Required. The JSON text |
| path | Optional. A path to an array inside the JSON |
Technical Details
| Return type: | Integer |
|---|
More Examples
Example
Count the items in an array inside an object:
SELECT JSON_ARRAY_LENGTH(
'{"names": ["Emil", "Nora"]}', '$.names');
Try it Yourself »