convert selected pg results into a json object