“Swift String to Dictionary” Código de respuesta

Swift Convertir datos a diccionario

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

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
}
Elated Eland

Respuestas similares a “Swift String to Dictionary”

Preguntas similares a “Swift String to Dictionary”

Más respuestas relacionadas con “Swift String to Dictionary” en Swift

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código