これはサーバーから受信したJSON応答です。私は成功していない値を解析しようとしました。Swift 3でこのJSON応答から値を解析する方法は?
{"items":
[{"item":
{ "id":824,
"company_id":31,
"config_id":45,
"imagesmall":null,
"imagethumb":null,
"pointofsales":null,
"status":true,
"endPlanned":false
}
},
{"item":
{ "id":889,
"company_id":74,
.
.
.
"status":true,
"endPlanned":false
}
}]
}
コードは、私はあなたがitems
配列をループする必要item
を印刷するには
if let json = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String: Any]{
print(json) // does work
let item = json?["items"] as? [[String: Any]]
print(item?[0]) // does work
// ... from here I am looking for the code to access the values and print it out ...
}
あなたが試したことを私たちに教えてください。 –
あなたの試しコードとそれで動作していないものはここにはありません(http://stackoverflow.com/posts/42000176/edit)。 –