2
我正试图通过发送数据到结构的JSON数组循环。Swift 3循环JSON数据
这里是我的代码,使用SwiftyJSON返回一个JSON
对象:
performAPICall() {
json in
if(json != nil){
print("Here is the JSON:")
print(json["content"]["clients"])
let clients = json["content"]["clients"]
for client in clients {
var thisClient = Client()
thisClient.id = client["id"].string
thisClient.desc = client["desc"].string
thisClient.name = client["name"].string
self.clientArray.append(thisClient)
}
self.tableView.reloadData()
} else {
print("Something went very wrong..,")
}
}
我不明白为什么我得到“无标”的错误在三根弦。
任何帮助表示赞赏,谢谢。
编辑:这里的JSON
{
"content": {
"clients": [{
"group": "client",
"id": "group_8oefXvIRV4",
"name": "John Doe",
"desc": "John's group."
}, {
"group": "client",
"id": "group_hVqIc1eEsZ",
"name": "Demo Client One",
"desc": "Demo Client One's description! "
}, {
"group": "client",
"id": "group_Yb0vvlscci",
"name": "Demo Client Two",
"desc": "This is Demo Client Two's group"
}]
}
}
你能后的JSON对象? – CodeBender
我已将它添加到问题中。 – Aloogy
不幸的是,我忘了包含顶级的“顶级”级别,但是如果我只是打印(json),那么它就很难对付。 – Aloogy