public void convert(Object from, BytesArray to) {
Assert.isTrue(from == null || from instanceof Tuple,
String.format("Unexpected object type, expecting [%s], given [%s]", Tuple.class, from.getClass()));
// handle common cases
Tuple tuple = (Tuple) from;
if (tuple == null || tuple.size() == 0) {
to.bytes("{}");
return;
}
Assert.isTrue(tuple.size() == 1, "When using JSON input, only one field is expected");
super.convert(tuple.getValue(0), to);
}