I am trying to do a simple JSON string to Object conversion. Here is the code:
let u = "somehost.com/api/1/ipa/2"
let url = NSURL(string: u )!
let data = NSData(contentsOfURL: url)!
let parsed: AnyObject? = try NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments)
if let json = parsed as? [String: AnyObject]{
// never enters this if statement.
}
But it will not unwrap correctly. Seems to me that this should be much simpler. Could someone please help? Also using "Xcode 7.3 and swift 2.2".
I want to avoid using a third party library.
[String:AnyObject]. Show the beginning of the JSON.as? [[String: AnyObject]] { ...{"a":"b","c":"d"}. Also it is not in a list. @NDoc