SELECT json_agg(row_to_json(*))
select array_to_json(array_agg(row_to_json(t))) from (select * from name) t