发布 json 编码参数 swift



你能建议我如何在 swift 或目标 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对象创建一个对象,然后将其作为参数传递给Alamofire。

最新更新