-3

I have JSON code which I need to parse on swift language

{
    data =     {
        id = "kUu6AXbbN2tEeCJJ22fdHh";
        name = Ralf;
    };
}

and this code which

if let myData = data{
    do{
    let myJson = try JSONSerialization.jsonObject(with: myData, options: 
JSONSerialization.ReadingOptions.mutableContainers) as AnyObject}
                    catch{    
                    }

In command line I can see my json structure and what I have inside but I can't understand how I can parse it. Can somebody help me please I just start working with swift

Hamish
  • 78,605
  • 19
  • 187
  • 280
Sergey
  • 1
  • 6

1 Answers1

-2
}

            if let myData = data{
                do{
                    let myJson = try JSONSerialization.jsonObject(with: myData, options: JSONSerialization.ReadingOptions.mutableContainers) as AnyObject
                    if let data = myJson["data"] as AnyObject? {
                        if let id = data["id"] as! NSString? {
                            print (id)
                        }
                        if let name = data["name"] as! NSString? {
                            print (name)
                        }
                    }
                }

                catch{

                }
                }
Sergey
  • 1
  • 6