convert objects to array and vice versa