Example: Array to JSON Type Conversion Using the ARRAY_TO_JSON Function - Advanced SQL Engine - Teradata Database

JSON Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
gzn1554761068186.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1150
lifecycle
previous
Product Category
Teradata Vantageā„¢
Use the ARRAY_TO_JSON function to convert an array to a JSON type composed of an ARRAY and return the data in both LATIN and UNICODE character sets.
SELECT (ARRAY_TO_JSON(a) RETURNS JSON(20) CHARACTER SET LATIN),
       (ARRAY_TO_JSON(b) RETURNS JSON(100) CHARACTER SET UNICODE)
FROM arrayTable;
Result:
ARRAY_TO_JSON(a)   ARRAY_TO_JSON(b)
----------------------------------------
[1,2,3,4,5]        [[1,2,3], [4,5,6], [7,8,9]]