Answers for "swift convert data to dictionary"

4

swift convert data to dictionary

do {
let json = try JSONSerialization.jsonObject(with: jsonData, options: [])
}
catch let e{ print(e.localizedDescription) }
Posted by: Guest on May-21-2022
2

swift convert data to dictionary

do{  
let json = try JSONSerialization.jsonObject(with: data!, options: []) as? [String : Any]
}catch{ print("erroMsg") }
Posted by: Guest on January-13-2022
0

swift string to dictionary

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
}
Posted by: Guest on April-07-2022

Code answers related to "swift convert data to dictionary"

Code answers related to "Swift"

Browse Popular Code Answers by Language