Customising Jersey JSON marshalling for java.util.Maps

萝らか妹 提交于 2020-01-14 14:56:10

问题


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'?


回答1:


Use a custom @XmlJavaTypeAdapter. @Blaise Doughan has a clearly-written tutorial on using them.

See also XmlAdapter.



来源:https://stackoverflow.com/questions/6252577/customising-jersey-json-marshalling-for-java-util-maps

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