如何获得匹配比赛的价值?我不知道如何使用这种结构检索Json数据。
lifeTimeStats = (
{
key = "Matches Played";
value = 764;
},
{
key = Score;
value = "126,830";
}
);
答案 0 :(得分:1)
你可以尝试,我希望你有json的数据
do {
var json = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String:Any]
if let current = json["lifeTimeStats"] as? [Any] {
if let Key_value = current[0] as? [String : Any] {
if let Score_String = Key_value["key"] as? String {
self.Score.text = Score_String
}
}
}
}
catch let err as NSError {
print(err)
}