Swift 3 ile basit JSON serileştirme prensiplerini anlayan bir zaman ayıyorum. Bir web sitesinden JSON kodunu çözme konusunda yardım alabilir miyim? Bu yüzden jsonResult["team1"]["a"]
vb. İlgili kod geçerli:Swift ile JSONSerialization 3
let httprequest = URLSession.shared.dataTask(with: myurl){ (data, response, error) in
self.label.text = "RESULT"
if error != nil {
print(error)
} else {
if let urlContent = data {
do {
let jsonResult = try JSONSerialization.jsonObject(with: urlContent, options:
JSONSerialization.ReadingOptions.mutableContainers)
print(jsonResult) //this part works fine
print(jsonResult["team1"])
} catch {
print("JSON Processing Failed")
}
}
}
}
httprequest.resume()
gelen JSON geçerli:
{
team1 = {
a = 1;
b = 2;
c = red;
};
team2 = {
a = 1;
b = 2;
c = yellow;
};
team3 = {
a = 1;
b = 2;
c = green;
};
}
Teşekkür Swift 3'te