I found the answer from this link:

select * from (
  select id,
    (
      select row_to_json(d)
      from (
        select name, addr
        from myt d
        where d.id=s.id
      ) d
    ) as data
  from myt s
)


Postgres multiple columns to json
We're (slowly) renovating the sash windows in our house and the current window is causing problems. What should have been a quick job (especially at this time of year!) has turned into a marathon because the putty won't dry.

We had to replace a couple of panes of glass (one was cracked and we broke another when using a heat gun to remove the paint) so we knew it would take a little while. On a previous window the putty took over three weeks to dry enough to paint partly because (as we thought) there was too much oil. So this time we rolled the putty on newspaper first to try to remove the excess oil. It seemed to work, but after two weeks the putty is still soft to the touch.

We've tried standing the windows next to a radiator but all that seemed to do was make it softer (which was obviously going to happen in hindsight).

So given that we don't want to reputty the windows what can we do to speed up the drying process.

We've had to seal off the room and cover the window as best we can in the meantime.

I've found this advice on DoItYourself.com which doesn't really help as it says use other materials!

The answers to this post on DIY-Forums are confusing at best and possibly contradictory as one recommends exposing the putty to moisture(!) to speed the drying process.
