Turning an object structure into an array