Uses PostgreSQL json aggregate function to wrap Active Record queries to directly output as json.