How to loop through JSON with SwiftyJSON?

后端 未结 5 1977
一向
一向 2020-12-13 08:59

I have a json that I could parse with SwiftyJSON :

if let title = json[\"items\"][2][\"title\"].string {
     println(\"title : \\(title)\")
}
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 09:40

    you can iterate through the json by:

    for (_,subJson):(String, JSON) in json {
    
       var title = subJson["items"]["2"]["title"].stringValue
    
       print(title)
    
    }
    

    have a look at the documentation of SwiftyJSON. https://github.com/SwiftyJSON/SwiftyJSON go through the Loop section of the documentation

提交回复
热议问题