I use devise for authentication and in registration controller if user cannot be created due to some reason then it produces json response as
{"email":["has already been taken"],"password":["doesn't match confirmation"],"username":["has already been taken"]}
but i want this to be changed to the following
{"error":{"email":{"has already been taken"},"password":{"doesn't match confirmation"},"username":{"has already been taken"}}}
How can i do this?