Chandan Jee Chandan Jee - 11 months ago 60
iOS Question

How to get NSDictionary from NSDictionary in Swift?

I am new in Swift.My json detail below.How to get dictionary of 'assdata' from AP0 Dictionary.Please detail briefly and step by step.

"AP0": {
"assdata": "{
\"Service Requested\":\" Equipment\",
\"Requested For\":\"Chandan\",
\"Requested Location\":\"\\\\Locations\\\\SBCBSC\\\\ SBCBSC - MAIN\",
\"Requested By\":\"Chandan\",
\"Request Id\":\"100067809074\",
"Linked Form": "Equipment",
"System Record ID": "17213450626",
"Submitted By": "Chandan",
"Linked Business Object": "Request",
"Linked Record": "100067809074-0",
"datastatus": "true"

Thanks In Advance.

Answer Source

You can try this.

let myJSON =  try NSJSONSerialization.JSONObjectWithData(urlData!, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary

            let keys = myJSON.allKeys

            let values = myJSON.allValues

            let dict = values[2]

            let dictAssdata = dict["assdata"]

Hope it help you.