How to parse JSON using Alamofire in Swift 3.0 without any third-party library

后端 未结 3 555
粉色の甜心
粉色の甜心 2021-01-15 07:57

Here I want to parse JSON via url. This is what actual JSON data available on url. So I need to parse it and read in my app using Alamofire. But I \'m unable to do it.

3条回答
  •  渐次进展
    2021-01-15 08:19

    You should use SwiftyJson, which is a library for json parsing, very usefull with Alamofire

    In your case you can do something like this with swiftyJson :

    //Array & Dictionary
    var jsonArray: JSON =  [
       "main": ["date": "2017-01-11", "USDARS": "15.8302"]
    ]
    
    let dateString = jsonArray["main"][0]["date"].string
    
    print(dateString) = "2017-01-11"
    

提交回复
热议问题