All Products
Search
Document Center

MaxCompute:JSON_OBJECT

Last Updated:Mar 26, 2026

Builds a JSON object from one or more key-value pairs.

Syntax

json json_object(<key1>, <value1> [, <keyn>, <valuen>])

Parameters

Parameter Required Type Description
key Yes STRING The key for each key-value pair.
value Yes STRING, BIGINT, INT, or BOOLEAN The value for each key-value pair.

Return value

A JSON value.

Examples

Single key-value pair

-- Build a JSON object with one key-value pair.
SELECT json_object('a', 123);

Output:

+------------+
| _c0        |
+------------+
| {"a":123}  |
+------------+

Multiple key-value pairs

-- Build a JSON object with multiple key-value pairs.
SELECT json_object('a', 123, 'b', 'hello');

Output:

+-----------------------+
| _c0                   |
+-----------------------+
| {"a":123,"b":"hello"} |
+-----------------------+

Related functions

json_object is a complex type function. For a full list of functions that process ARRAY, MAP, STRUCT, and JSON data, see Complex type functions.