There is not yet an equivalent to GROUP_CONCAT that produces a JSON array. (There is in MySQL 8, but that’s not GA yet.) Until then, you can hack it together with string functions:
SELECT * FROM t; +------+--------+ | id | data | +------+--------+ | 1 | First | | 2 | Second | +------+--------+ SELECT CONCAT('[', GROUP_CONCAT(JSON_OBJECT('id', id, 'value', data) SEPARATOR ', '), ']') AS j FROM t; +-------------------------------------------------------------+ | j | +-------------------------------------------------------------+ | [{"id": 1, "value": "First"}, {"id": 2, "value": "Second"}] | +-------------------------------------------------------------+
Or you can use all JSON functions but hack the grouping:
SELECT j FROM ( SELECT @c := @c + 1 AS c, @j := JSON_MERGE(@j, JSON_OBJECT('id', id, 'value', data)) AS j FROM t JOIN (SELECT @c := 0, @j := JSON_ARRAY()) dt1 ) dt2 ORDER BY c DESC LIMIT 1; +-------------------------------------------------------------+ | j | +-------------------------------------------------------------+ | [{"id": 1, "value": "First"}, {"id": 2, "value": "Second"}] | +-------------------------------------------------------------+