parse response from postgres to json before sending