从Jersey 1.19升级到Jersey 2.25后,我的json响应发生了变化。
我有一个属性如下。
@XmlElementWrapper(name = "items")
@XmlElement(name = "contact")
public List<Contact> items = new ArrayList<Contact>();
在泽西岛1.19
JSON
{
"items": [
{
"id": "510651"
}
]
}
XML
<items>
<contact>
..
..
</contact>
</items>
升级到球衣2.25之后,xml看起来很好,但是Json存在问题。
Json升级后
{
"contact": [
{
"id": "510651"
}
]
}
我的泽西配置低于
public JerseyConfig() {
packages("my.api");
property(ServerProperties.WADL_FEATURE_DISABLE, true);
register(RequestContextFilter.class);
register(JacksonFeature.class);
register(CacheControlFilter.class);
register(GZipEncoder.class);
register(new LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), Level.INFO,
LoggingFeature.Verbosity.PAYLOAD_TEXT, 10 * 1024));
register(new AbstractBinder() {
@Override
public void configure() {
bindFactory(LocaleFactory.class).to(Locale.class).in(RequestScoped.class);
}
});
}
答案 0 :(得分:1)