开发者

Customising Jersey JSON marshalling for java.util.Maps

开发者 https://www.devze.com 2023-03-11 04:55 出处:网络
By default, marshalling a @XmlRootElement bean containing a map gives the structure: myMap : { entry : {

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 'e开发者_运维百科ntry', 'key' and 'value'?


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

See also XmlAdapter.

0

精彩评论

暂无评论...
验证码 换一张
取 消