How could we convert a string to an object in a simpler way?