Properly return org.w3c.dom.Document as JSON using Jersey

断了今生、忘了曾经 提交于 2019-12-12 04:45:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!