Unify toTable for object and array