VeloDB Cloud
SQL Manual
Functions
json-functions
json_object

json_object

Description

Syntax:

VARCHAR json_object(VARCHAR,...)

This function generates a json object containing the specified Key-Value. If key is null or the number of the input arguments is odd, it will return an exception error.

Example

MySQL> select json_object();
+---------------+
| json_object() |
+---------------+
| {}            |
+---------------+

MySQL> select json_object('time',curtime());
+--------------------------------+
| json_object('time', curtime()) |
+--------------------------------+
| {"time": "10:49:18"}           |
+--------------------------------+


MySQL> SELECT json_object('id', 87, 'name', 'carrot');
+-----------------------------------------+
| json_object('id', 87, 'name', 'carrot') |
+-----------------------------------------+
| {"id": 87, "name": "carrot"}            |
+-----------------------------------------+


MySQL> select json_object('username',null);
+---------------------------------+
| json_object('username', 'NULL') |
+---------------------------------+
| {"username": NULL}              |
+---------------------------------+

Keywords

json,object,json_object