I have a REST service built with Jersey and deployed in the AppEngine. The REST service implements the verb PUT that consumes an application/json
media type. Th
This is the solution for my old question:
I implemented my own ContextResolver
in order to enable the DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY
feature.
package org.lig.hadas.services.mapper;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
@Produces(MediaType.APPLICATION_JSON)
@Provider
public class ObjectMapperProvider implements ContextResolver
{
ObjectMapper mapper;
public ObjectMapperProvider(){
mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
}
@Override
public ObjectMapper getContext(Class> type) {
return mapper;
}
}
And in the web.xml
I registered my package into the servlet definition...
...
com.sun.jersey.spi.container.servlet.ServletContainer
com.sun.jersey.config.property.packages
...;org.lig.hadas.services.mapper
...
... all the rest is transparently done by jersey/jackson.