问题
I have a function which returns type org.w3c.dom.Document, and my Jersey resource lets it return either as XML or JSON. It returns the XML fine, however, for JSON, it returns a simple string, which is just the XML using Application/JSON. How can I make it encode to JSON properly?
I'm open to changing the return type of the function to something that can properly be serialized by Jersey
回答1:
You would have to write your own MessageBodyWriter for application/json media type and org.w3c.dom.Document class.
来源:https://stackoverflow.com/questions/7101000/properly-return-org-w3c-dom-document-as-json-using-jersey