JSON in MySQL : get data from an object within a range of keys
Possible realization:
WITH RECURSIVE cte AS ( SELECT @from num
                        UNION ALL
                        SELECT num+1 FROM cte WHERE num &lt; @till )
SELECT CONCAT('key', num) `key`, 
       JSON_EXTRACT(test.val, CONCAT('$.key', num)) `value`
FROM test
CROSS JOIN cte
HAVING `value` IS NOT NULL;

fiddle