String s;
if (o instanceof ByteBuffer) {
// special case since GenericData.toString() is incorrect for bytes
// note that this does not handle the case of a default value with nested bytes
ByteBuffer bytes = ((ByteBuffer) o);
bytes.mark();
byte[] data = new byte[bytes.remaining()];
bytes.get(data);
bytes.reset(); // put the buffer back the way we got it
s = new String(data, "ISO-8859-1");
char[] quoted = JsonStringEncoder.getInstance().quoteAsString(s);