2
構造体にデータを送信するJSON配列をループしようとしています。私は3つの文字列でのエラー「何の添字を持っていない」そうだ、なぜ非常にわからないSwift 3 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
オブジェクトを返すためにSwiftyJSONを使用して私のコードです。
ご協力いただきありがとうございます。
EDIT:は、ここにあなたがarray
メソッドを使用する必要があります
{
"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