bookmark

Missing Brackets At JSON One-Element Arrays In Jersey (Japod's blog)


Description

@Provider public class JAXBContextResolver implements ContextResolver<JAXBContext> {

private JAXBContext context; private Class[] types = {ArrayWrapper.class};

public JAXBContextResolver() throws Exception { Map props = new HashMap<String, Object>(); props.put(JSONJAXBContext.JSON_NOTATION, "MAPPED"); props.put(JSONJAXBContext.JSON_ROOT_UNWRAPPING, Boolean.TRUE); props.put(JSONJAXBContext.JSON_ARRAYS, "[\"list\"]"); this.context = new JSONJAXBContext(types, props); }

public JAXBContext getContext(Class<?> objectType) { return (types[0].equals(objectType)) ? context : null; } }

Preview

Tags

Users

  • @folke

Comments and Reviews