Move JSON handling out of Endpoints.hs