Convert key to Dict key type before hashing