I have a simple RESTful method which currently returns JSON representation of an object.
My question is more of from the architectural perspective and not completely technical.
Should a RESTful service be designed in such a way that it returns both JSON and XML at the same time?
As far as I know this is a bad practice and separate resources should be defined for this. One resource should return JSON data and other one XML.
Am I thinking it correctly?
The same resource may return either XML or JSON depending upon the request, but it shouldn't return both at the same time. You will know which one to return based upon the request, so there is no need to generate both -- just generate the one you'll be returning.
Here is how you might choose to decide which to return. Evaluate in order, stopping when you've determined the format to return:
GET /user/1234.xml), use that as the requested format.