SQLite 3 reference · JSON Functions
SQLite JSON_ARRAY() Function
Build a JSON array from the arguments. SQL NULL becomes JSON null; numbers stay numbers.
SQLite 3 Since 3.9.0
Syntax
json_array(value1, value2, ...)
Parameters
| Parameter | Description |
|---|---|
values |
The array elements. |
Return value
JSON array text.
Examples
SELECT json_array(1, 'two', NULL, 4.5) AS arr;
Output
arr [1,"two",null,4.5]
SELECT json_array(name, price) AS pair
FROM products
LIMIT 2;
Output
pair ["SQL for Beginners",29.99] ["Clean Code",37.5]
Version history
| Version | Change |
|---|---|
| SQLite 3.9.0 | Added |
| SQLite 3.38.0 | Built in by default; earlier versions needed the JSON1 extension. |
In other languages
JSONB_BUILD_ARRAY()· PostgreSQL
Related
JSON_OBJECT()· Build a JSON object from key and value pairs. SQL NULL becomes JSON null; nested json() values stay JSON.JSON_GROUP_ARRAY()· Aggregate the values of a group into one JSON array, one element per row. SQL NULLs become JSON null.JSON_ARRAY_LENGTH()· Return the number of elements in a JSON array, optionally at a path. Non-arrays give 0.- SQL String Functions · tutorial