int start = buffer.position();
try {
json.writeValue(object, Object.class, null);
writer.flush();
} catch (Exception ex) {
throw new JsonException("Error writing object: " + object, ex);
}
if (INFO && logging) {
int end = buffer.position();
buffer.position(start);
buffer.limit(end);