Swift Convert Data To Dictionary

[Solved] Swift Convert Data To Dictionary | Swift - Code Explorer | yomemimo.com
Question : swift convert data to dictionary

Answered by : velmurugan

do {
let json = try JSONSerialization.jsonObject(with: jsonData, options: [])
}
catch let e{ print(e.localizedDescription) }

Source : | Last Update : Sat, 28 May 22

Question : swift convert data to dictionary

Answered by : ahsan-lwa8tagab3go

do{
let json = try JSONSerialization.jsonObject(with: data!, options: []) as? [String : Any]
}catch{ print("erroMsg") }

Source : https://stackoverflow.com/questions/39427500/swift-3-0-data-to-json-string-any | Last Update : Thu, 20 Jan 22

Question : swift string to dictionary

Answered by : elated-eland-a3nxocesv3qu

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
}

Source : https://stackoverflow.com/questions/30480672/how-to-convert-a-json-string-to-a-dictionary | Last Update : Thu, 14 Apr 22

Answers related to swift convert data to dictionary

Code Explorer Popular Question For Swift