问题
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