Answers for "string to swift 2022"

0

string to swift 2022

let jsonText = "{\"first_name\":\"Sergey\"}"
        var dictonary:NSDictionary?
        
        if let data = jsonText.data(using: String.Encoding.utf8) {
            
            do {
                dictonary = try JSONSerialization.jsonObject(with: data, options: []) as? [String:AnyObject]
            
                if let myDictionary = dictonary
                {
                     print(" First name is: \(myDictionary["first_name"]!)")
                }
            } catch let error as NSError {
                print(error)
            }
        }
Posted by: Guest on April-13-2022

Code answers related to "Swift"

Browse Popular Code Answers by Language