Replace circular references in an object with a string