DB2 Scalar functions - JSON_ARRAY
The JSON_ARRAY function generates a JSON array by explicitly listing the array elements by using JSON-expression, or by using a query.
Although the schema for this function is SYSIBM, the function cannot be specified as a qualified name.
The result type of this expression can be any built-in data type, except the following data types (SQLSTATE 42815):
If the generated value is numeric, it cannot be Infinity, NaN, or sNaN (SQLSTATE 22023).
If FORMAT JSON or FORMAT BSON is not specified, and the generated value is not numeric, any special characters (for example, backslash or double quotation marks) within the result string are escaped.
If FORMAT JSON or FORMAT BSON is not specified and JSON-expression is binary string type, it is interpreted as FORMAT BSON.
If JSON-expression is a character string data type, it is treated as JSON data.
If JSON-expression is a binary string data type, it is interpreted as UTF-8 data.
The result type of this column cannot be any of the following data types (SQLSTATE 42815):
If FORMAT JSON or FORMAT BSON is not specified and the generated value is not numeric, any special characters (for example, backslash or double quotation marks) within the result string are escaped.
If FORMAT JSON or FORMAT BSON is not specified and the fullselect is binary string type, it is interpreted as FORMAT BSON.
If fullselect is a character string data type, it is treated as JSON data.
If fullselect is a binary string data type, it is interpreted as UTF-8 data.
See CREATE TABLE statement for the description of built-in data types.
VALUES JSON_ARRAY('Washington', 'Jefferson', 'Hamilton'); 1 ------------------------------------- ["Washington","Jefferson","Hamilton"]
VALUES JSON_ARRAY(SELECT DEPTNO FROM DEPT); 1 ------------------------------- ["F22","G22","H22","I22","J22"]>