Support encoding of generic iterable objects as arrays