Parsing JSON data from alamofire into Array with Dictionary

后端 未结 3 2028
名媛妹妹
名媛妹妹 2021-01-20 01:26

I\'m trying to parse JSON data from alamorefire as follows.

import UIKit
import Alamofire
import SwiftyJSON

class ViewController: UIViewController {
    ove         


        
3条回答
  •  日久生厌
    2021-01-20 01:48

    Alamofire.request("YOUR_URL", method:.post, parameters:params, encoding:URLEncoding.default, headers: nil).responseJSON { response in
        switch(response.result)
        {
        case .success(_):
            if response.result.value != nil
            {
                let dict :NSDictionary = response.result.value! as! NSDictionary
                print(dict)
                let status = dict.value(forKey: "status")as! String
                print(status)
                if(status=="1")
                {
    
                    self.array_placeRequestId=((dict.value(forKeyPath: "result.request_id") as! NSArray).mutableCopy() as! NSMutableArray)
    
    
                }
                else
                {
                   print("Something Missed")
                }
            }
            break
    
        case .failure(_):
            print(response.result.error)
            break
        }
    }
    

提交回复
热议问题