How do I use JSON arrays with Alamofire parameters?

前端 未结 8 1980
借酒劲吻你
借酒劲吻你 2021-01-05 01:03

I\'m having a bit of trouble structuring my parameters so that our server API would be able to read it as valid JSON.

Alamofire uses parameters like this in swift la

8条回答
  •  耶瑟儿~
    2021-01-05 01:19

    Swift 2.2 and using SwiftyJSON.swift
    You can use like this.

        var arrayList : [String: AnyObject]//one item of array
    
        var list: [JSON] = []//data array 
    
        for i in 0..<10//loop if you need
        { 
    
            arrayList = [
                "param1":"",
                "param1":"",
                "param2":["","",""]
            ]
    
            list.append(JSON(arrayList))//append to your list
    
        }
    
    
        //params
        let params: [String : AnyObject]=[
    
            "Id":"3456291",
            "List":"\(list)"//set
        ]
    

提交回复
热议问题