0
我正在使用SwityJSON遍历我的JSON数据并解析它。它工作正常,但我想确保我正确和高效地使用该语法。请仔细阅读下面我的代码:用SwiftyJSON解析的正确方法
if let itemDict = json[0]["artists"].dictionaryValue {
for item in itemDict {
if let artist: Dictionary? = item.1.dictionaryValue {
// artist id
if let artistId = artist?["id"] {
if artistId.stringValue != nil {
// add value to object
}
}
// title
if let title = artist?["title"] {
if title.stringValue != nil {
// add value to object
}
}
// subtitle
if let subtitle = artist?["subtitle"] {
if subtitle.stringValue != nil {
// add value to object
}
}
// image url
if let imageURL = artist?["imageURL"] {
if imageURL.stringValue != nil {
// add value to object
}
}
}
}
}