@Override
 public final byte[] serialize(MediaContent content) throws IOException {
   ByteArrayOutputStream baos = outputStream(content);
   JsonGenerator generator = constructGenerator(baos);
   writeMediaContent(generator, content);
   generator.close();
   return baos.toByteArray();
 }
 @Override
 public final void serializeItems(MediaContent[] items, OutputStream out) throws IOException {
   JsonGenerator generator = constructGenerator(out);
   // JSON allows simple sequences, so:
   for (int i = 0, len = items.length; i < len; ++i) {
     writeMediaContent(generator, items[i]);
   }
   generator.close();
 }