@Override
    public void render(OutputStream outputStream) throws IOException {
        ObjectWriter writer = prettyPrint ? jsonMapper.writerWithDefaultPrettyPrinter() : jsonMapper.writer();
        if (log.isLoggable(Level.FINE)) {
            String json = writer.writeValueAsString(entity);
            log.log(Level.FINE, "Writing the following JSON to response output stream:\n" + json);
            outputStream.write(json.getBytes());
        } else {
            writer.writeValue(outputStream, entity);
        }
    }
A JSON response using Jackson for serialization.

@author bjorncs
container-core/src/main/java/com/yahoo/restapi/JacksonJsonResponse.java