I was going over some of the new JSON features and was wondering if there is a clever (or obvious) way to return a rowset as a JSON object. Ideally without having to name the keys or use any kind of string manipulation.
Example:
TABLE: people
id name age
1 bob 54
2 jay 32
3 john 10
SELECT * FROM people where id = 1
would return
{"id":1,"name":"bob","age":54}
Or even better
SELECT * FROM people
would return an array of all 3 objects
If you are not familiar with the new JSON features, one of the new functions is JSON_OBJECT
SELECT JSON_OBJECT('key1', 1, 'key2', 'abc')
would return a key value JSON object.