Purpose
You can call this function to return a JSON object based on the key-value pair that you specified.
Syntax
JSON_OBJECT([key, val[, key, val] ...])
Notes
key, val represents a key-value pair. If the number of arguments is odd, an error is returned.
Examples
obclient> SELECT JSON_OBJECT('id', 69, 'name', 'apple');
+----------------------------------------+
JSON_OBJECT('id', 69, 'name', 'apple')
+----------------------------------------+
{"id": 69, "name": "apple"}
+----------------------------------------+
1 row in set
obclient> SELECT JSON_OBJECT('id', 69, 'name', 'apple', 100);
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'JSON_OBJECT'
obclient> SELECT JSON_OBJECT('id', 69, 'name', 'apple', 100, 'good');
+-----------------------------------------------------+
JSON_OBJECT('id', 69, 'name', 'apple', 100, 'good')
+-----------------------------------------------------+
{"id": 69, "100": "good", "name": "apple"}
+-----------------------------------------------------+
1 row in set
obclient> SELECT JSON_OBJECT();
+---------------+
JSON_OBJECT()
+---------------+
{}
+---------------+
1 row in set
obclient> SELECT JSON_OBJECT('id', 69, 'name', 'apple', '[100,200]','{names:tim}');
+-------------------------------------------------------------------+
JSON_OBJECT('id', 69, 'name', 'apple', '[100,200]','{names:tim}')
+-------------------------------------------------------------------+
{"id": 69, "name": "apple", "[100,200]": "{names:tim}"}
+-------------------------------------------------------------------+
1 row in set