繁体   English   中英

如何快速解析此JSON数据

[英]How to parse this JSON data in swift

从网络服务器解析json数据时遇到问题。 如果有人可以帮助我,我将非常感激。 我在iOS应用程序中使用swift。 任何参考文献也将有很大帮助。

[
{
    "0": "M26177M21MUG",
    "1": "Imbwa yigisha umwana gukambakamba",
    "2": "147746956612e34",
    "3": "2016/10/26",
    "4": "Amazing Video",
    "5": "2016-10-26",
    "videokey": "M26177M21MUG",
    "title": "Imbwa yigisha umwana gukambakamba",
    "file_name": "147746956612e34",
    "file_directory": "2016/10/26",
    "description": "Amazing Video",
    "datecreated": "2016-10-26"
},
{
    "0": "HDYBX1NOBBU7",
    "1": "KIGALI NZIZA 2016 2040",
    "2": "1477409119f676f",
    "3": "2016/10/25",
    "4": "KIGALI NZIZA 2016 2040",
    "5": "2016-10-25",
    "videokey": "HDYBX1NOBBU7",
    "title": "KIGALI NZIZA 2016 2040",
    "file_name": "1477409119f676f",
    "file_directory": "2016/10/25",
    "description": "KIGALI NZIZA 2016 2040",
    "datecreated": "2016-10-25"
},
{
    "0": "6ANO5UXHAD76",
    "1": "Umugabo yigishije imbwa ye gusenga mbere yo kurya",
    "2": "147746949813fd9",
    "3": "2016/10/26",
    "4": "NGWINO by KNC New Rwandan music 2013",
    "5": "2016-10-26",
    "videokey": "6ANO5UXHAD76",
    "title": "Umugabo yigishije imbwa ye gusenga mbere yo kurya",
    "file_name": "147746949813fd9",
    "file_directory": "2016/10/26",
    "description": "NGWINO by KNC New Rwandan music 2013",
    "datecreated": "2016-10-26"
}]

我获取数据的链接是:

http://marieadelaideschool.rw/stream/api/vod.php

我认为使用Alamofire的此示例功能将对您有所帮助...

func callApi()
{
    Alamofire.request(.GET, "http://marieadelaideschool.rw/stream/api/vod.php", encoding: .JSON).responseJSON
        {
            response in switch response.2
            {
            case .Success(let JSON):
                print(JSON)
                let responseData = JSON as! NSArray
                for i in responseData
                {
                    let object = i as! NSDictionary
                    let title = object["title"]
                    print(title!)
                }
                break
            case .Failure(let error):
                print("Request failed with error: \(error)")
                break
            }

    }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM