Skip to content

JSONOBJECTAGG() alternative in MariaDBΒΆ

While the function is supported in MySQL, it is not in MariaDB. The workaround is to use something like this:

NOTE: this will not work with strings that have quotes in them, it will render a broken JSON.

SELECT
 CONCAT("{", GROUP_CONCAT(DISTINCT CONCAT('"', 'key', '": "',
                      'value', '"') SEPARATOR ', '), "}") json

mariadb_jsonobjagg_example.png