Added a helper for returning json in API so appropriate status codes return