package dk.thoerup.webservice; import java.util.HashMap; import java.util.Map; import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; import org.glassfish.jersey.moxy.json.MoxyJsonConfig; @Provider public class JsonMoxyConfigurationContextResolver implements ContextResolver { private final MoxyJsonConfig config; public JsonMoxyConfigurationContextResolver() { System.out.println("Configuring Moxy"); final Map namespacePrefixMapper = new HashMap(); namespacePrefixMapper.put("http://www.w3.org/2001/XMLSchema-instance", "xsi"); config = new MoxyJsonConfig() .setNamespacePrefixMapper(namespacePrefixMapper) .setNamespaceSeparator(':') // .setAttributePrefix("") // .setValueWrapper("value") // .property(JAXBContextProperties.JSON_WRAPPER_AS_ARRAY_NAME, true) .setFormattedOutput(false) .setIncludeRoot(false) .setMarshalEmptyCollections(false); } @Override public MoxyJsonConfig getContext(Class objectType) { return config; } }