@Override
 public void writeTo(
     Association assoc,
     Class<?> type,
     Type genericType,
     Annotation[] annotations,
     MediaType mediaType,
     MultivaluedMap<String, Object> httpHeaders,
     OutputStream entityStream)
     throws IOException, WebApplicationException {
   try {
     BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(entityStream));
     assoc.toJSON().write(writer);
     writer.flush();
   } catch (Exception e) {
     throw new IOException("Writing message body failed (" + assoc + ")", e);
   }
 }