toString function for an object with key:value pairs.