Reputation: 343
How do I get the value of Matches Played and Score? I don't know how to retrieve the Json data with this structure.
lifeTimeStats = (
{
key = "Matches Played";
value = 764;
},
{
key = Score;
value = "126,830";
}
);
Upvotes: 1
Views: 51
Reputation: 100541
You can try , I expect you have the data of that 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)
}
Upvotes: 1