adds function for reading an object's fields