Im trying to covert this string into a dictionary
{
"sender_id": 7,
"Sender_name": Testchumthree Tester,
"message": 42,
"Sender_image": https://graph.facebook.com/v2.10/281359099024687/picture?type=normal,
"timestamp": "0",
"group_id": 50
}
Below is what i found so far.
func convertToDictionary(text: String) -> [String: Any]? {
if let data = text.data(using: .utf8) {
do {
return try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
} catch {
print(error.localizedDescription)
}
}
return nil
}
But this i get an error saying the data is not in the correct format. Any help would be much appreciated.