public void writeTo(Blob blob, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {
try {
JsonFormat.serialize(BlobConverter.toJson(blob), new CloseShieldOutputStream(entityStream));
} catch (Throwable e) {
// We catch every throwable, since otherwise no one does it and we will not have any trace
// of Errors that happened.
throw new ResourceException("Error serializing entity.", e, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}