簡體   English   中英

發布 json 編碼參數 swift

[英]Post json encode parameter swift

你能建議我如何在swift或objective c中傳遞以下參數嗎

         let parameters = ["Access_Key":"0699DADD8A2B5FC2E8FF6FF5DDFE03EEDB3ED2132B29EA4F28","Packages":["Length":self.Length,"Type":"","Kg":self.Weight,"Height":self.Height,"Width":self.Width,"Name":self.SkuName],
                      "issignaturerequired":"true",
                      "Outputs":["LABEL_PNG_100X175"],
                      "DeliveryReference":"86882",
                      "Destination":["ContactPerson":self.CustomerFirstname,"Address":["PostCode":self.PostalCode,"StreetAddress":self.Address1,"Suburb":self.City,"BuildingName":"","City":self.City,"CountryCode":"AU"],"PhoneNumber":"","Email":self.CustomerEmail,"Name":self.CustomerFirstname],
                      "PrintToPrinter":"true",
                      "SendTrackingEmail":"",
        "Commodities":["UnitKg":"1.0000","Currency":"NZD","Country":"NZ","Units":"1","Description":"Drums Drum Accessories Drum Bags","UnitValue":"44.0"],
        "DeliveryInstructions":"None"
                     ]
    Alamofire.request(.POST, "http://api.omniparcel.com/labels/printcheapestcourier",parameters: parameters, encoding: .JSON)
        .responseJSON { response in
            print(response)
    }
}

我是 iOS 新手

我建議您在 Swift 中為 JSON 對象使用EVReflection

只需為您的 JSON 對象創建一個對象,然后使用myJsonObject.toDictionary()作為參數將其傳遞給 Alamofire。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM