0
我该如何解析这个JSON?swift从URL解析JSON
{
"telefon":"05538690671"
}
我的代码:
let url = NSURL(string: "http://localhost.192.168.1.40.xip.io:8888/store1.php")
//fetching the data from the url
URLSession.shared.dataTask(with: (url as URL?)!, completionHandler: {(data, response, error) -> Void in
if let jsonObj = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? NSDictionary {
//printing the json in console
print(jsonObj!.value(forKey: "telefon")!)
对不起我的英语
遗憾,当我从跟踪这个dataTask跳码到结束的代码 –
@ÜmitGündüz这意味着的'guard'条件之一已经失败。 –
@ÜmitGündüz我添加了一个新版本,在某些失败情况下调试更多。 –