为 java.util.Maps 自定义 Jersey JSON 编组
默认情况下,编组包含映射的 @XmlRootElement
bean 会给出以下结构:
myMap : {
entry : {
key : {
...
},
value : {
...
}
}
}
是否有任何方法可以自定义 JSON 字段名称“entry”、“key”和“value”?
By default, marshalling a @XmlRootElement
bean containing a map gives the structure:
myMap : {
entry : {
key : {
...
},
value : {
...
}
}
}
Is there any way to customise the JSON field names 'entry', 'key' and 'value'?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用自定义
@XmlJavaTypeAdapter
。 @Blaise Doughan 有一个 关于使用它们的清晰编写的教程。另请参见
XmlAdapter
。Use a custom
@XmlJavaTypeAdapter
. @Blaise Doughan has a clearly-written tutorial on using them.See also
XmlAdapter
.