top of page
CerebroSQL

MySQL: 

JSON_OBJECT

Syntax:
JSON_OBJECT([key, val[, key, val] ...])

Evaluates a (possibly empty) list of key-value pairs and returns a JSON
object containing those pairs. An error occurs if any key name is NULL
or the number of arguments is odd.

URL: https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html

Example

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

bottom of page