使用Jersey正确返回org.w3c.dom.Document作为JSON [英] Properly return org.w3c.dom.Document as JSON using Jersey

查看:90
本文介绍了使用Jersey正确返回org.w3c.dom.Document作为JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个返回org.w3c.dom.Document类型的函数,而我的Jersey资源允许它以XML或JSON的形式返回.它返回XML的罚款,但是,对于JSON,它返回一个简单的字符串,它只是使用Application/JSON的XML.如何使其正确编码为JSON?

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?

我愿意将函数的返回类型更改为可以由Jersey正确序列化的东西

I'm open to changing the return type of the function to something that can properly be serialized by Jersey

推荐答案

您将必须编写自己的

You would have to write your own MessageBodyWriter for application/json media type and org.w3c.dom.Document class.

这篇关于使用Jersey正确返回org.w3c.dom.Document作为JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆