There is a better option with json_build_object() in Postgres 9.4+

SELECT id, json_build_object('name', name, 'addr', addr) AS data
FROM   myt;


But there is also a simpler and faster way with row_to_json() in pg 9.3:

SELECT id, row_to_json((SELECT d FROM (SELECT name, addr) d)) AS data
FROM   myt;


SQL Fiddle.
Cast to ::text is only for a sanitized display in  the fiddle.

Related answers:


PostgreSQL : select columns inside json_agg
Return as array of JSON objects in SQL (Postgres)
Return total number of rows and selected (aggregated) data


Postgres multiple columns to json
I work as a kitchen aide in an assisted living community. I assist the cooks in some aspects of kitchen prep (mostly non-cooking), but occasionally I help in the actual cooking of food. For breakfast, oatmeal is served every morning. The residents enjoy the creaminess of the oatmeal when milk is added, but for those who are lactose intolerant I cannot take that risk. So what alternatives to milk can I use to create a creamier oatmeal? 
