json_array
1. JSON_ARRAY Function
=======json_array
1. JSON_ARRAY Function
>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62beThe JSON_ARRAY function in H2 database is used to create a JSON array containing the specified values.
2. Syntax
The syntax for the JSON_ARRAY function in H2 database is as follows:
JSON_ARRAY(value1, value2, ...)
Arguments
value1
,value2
, ...: The values to be included in the JSON array. These can be any valid H2 data types.
Return
- The JSON_ARRAY function returns a JSON array containing the specified values.
3. Notes
- All the values provided as arguments to the JSON_ARRAY function will be converted to their corresponding JSON representation.
- If any argument is a NULL value, it will be included as
null
in the resulting JSON array. - The JSON_ARRAY function can be useful when constructing JSON data for storage or retrieval purposes.
4. Examples
Here are a few examples demonstrating the usage of the JSON_ARRAY function in H2 database:
Example 1 - Creating a JSON array with multiple values:
SELECT JSON_ARRAY(1, 'John', true, 3.14) AS json_array;
Output:
json_array
---------------------------
[1, "John", true, 3.14]
Example 2 - Creating a JSON array with NULL values:
SELECT JSON_ARRAY(10, NULL, 'Hello', NULL, 5) AS json_array;
Output:
json_array
---------------------------
[10, null, "Hello", null, 5]
5. Related Functions
- json_object - Create a JSON object from key-value pairs.
- JSON_ARRAYAGG - Aggregate values into a JSON array.