don't wrap String responses with double quotes

This commit is contained in:
Athou
2013-08-12 20:50:03 +02:00
parent 321260b0a5
commit d66ca05dca

View File

@@ -15,6 +15,7 @@ import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
import org.apache.commons.io.Charsets;
import org.apache.http.HttpHeaders;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -37,9 +38,14 @@ public class JsonProvider implements MessageBodyReader<Object>, MessageBodyWrite
httpHeaders.putSingle(HttpHeaders.CACHE_CONTROL, CACHE_CONTROL_VALUE);
httpHeaders.putSingle(HttpHeaders.PRAGMA, CACHE_CONTROL_VALUE);
if (type.equals(String.class)) {
entityStream.write(value.toString().getBytes(Charsets.UTF_8));
} else {
getMapper().writeValue(entityStream, value);
}
}
@Override
public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {