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