Swift конвертирует данные в словарь
do {
let json = try JSONSerialization.jsonObject(with: jsonData, options: [])
}
catch let e{ print(e.localizedDescription) }
Vel
do {
let json = try JSONSerialization.jsonObject(with: jsonData, options: [])
}
catch let e{ print(e.localizedDescription) }
do{
let json = try JSONSerialization.jsonObject(with: data!, options: []) as? [String : Any]
}catch{ print("erroMsg") }
func convertStringToDictionary(text: String) -> [String:AnyObject]? {
if let data = text.data(using: .utf8) {
do {
let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String:AnyObject]
return json
} catch {
print("Something went wrong")
}
}
return nil
}