I have a String
example:
"['name': 'consumer_nam', 'date': 'date']"
I want to convert this to a dictionary type in Swift4.
I have a String
example:
"['name': 'consumer_nam', 'date': 'date']"
I want to convert this to a dictionary type in Swift4.
Dictionaries in Swift can be represented by [String : Any]
, and many other ways.
let dictionary : [String : Any] = ["name" : "consumer_nam", "date" : "date"]
If what you're trying to do is parse the String, you can take a look here and here.
It looks like your String is supposed to be interpreted as a Dictionary. It looks a bit like a textual representation of JSON.
Find a spec for the exact format of that String, and then you write code to parse it.
It may be easier to convince whoever produced that string to produce for example a JSON document instead (which would be stored as Data, not String).