Make setDataFromObject more versatile