2017-02-26 18 views
-1

私はすぐに素早く新しいAPIリクエストをリクエストしようとしています。 while it works just fine on postmanスウィフトのJSON本体でHTTP POSTリクエストを作成

ここには、httpBodyとしてバックエンドが必要なJSON文字列があります。

myJSON ={"address1":"Mirpur","address2":"D6, f8","cellPhone":"01852540565","city":"fghff","countryName":"Bangladesh","orderDate":"2017-02-25T11:28:24","orderStatus":1,"orderedProductList":[{"discount":0.0,"orderDetailId":0,"price":30000.0,"quantity":1,"shippingCharge":50.0,"supplierId":0,"tax":0.0,"type":{"isBook":false,"typeId":0},"productId":5,"productViews":0},{"discount":0.0,"orderDetailId":0,"price":50000.0,"quantity":1,"shippingCharge":50.0,"supplierId":0,"tax":0.0,"type":{"isBook":false,"typeId":0},"productId":8,"productViews":0},{"discount":0.0,"orderDetailId":0,"price":2000.0,"quantity":1,"shippingCharge":50.0,"supplierId":0,"tax":0.0,"type":{"isBook":false,"typeId":0},"productId":9,"productViews":0}],"paymentTransactionId":"1215455638874521","state":"fyy","zip":"4525","countryId":23,"orderId":0,"orderTotal":82000.0,"paymentMethodId":1,"userId":0} 

これをどのように修正すれば非常に役立つでしょうか。このような提案@deadbeef構文を使用して

+0

辞書構文は、このケースでも、 ' – deadbeef

+0

あなたを' [] '迅速ではなく、' {}を使用しています'let jsonObject:[String:Any] = ... ' – deadbeef

+1

POST要求を行う場合は、[Alamofire](https://github.com/Alamofire/Alamofire)を試してください – deadbeef

答えて

0

が動作するはず おかげで、myJSONを再フォーマット:

let myJSON: [String : Any] = ["address1":"Mirpur", 
           "address2":"D6, f8", 
           "cellPhone":"01852540565", 
           "city":"fghff", 
           "countryName":"Bangladesh", 
           "orderDate":"2017-02-25T11:28:24", 
           "orderStatus":1, 
           "orderedProductList":[ 
            ["discount":0.0, 
            "orderDetailId":0, 
            "price":30000.0, 
            "quantity":1, 
            "shippingCharge":50.0, 
            "supplierId":0, 
            "tax":0.0, 
            "type":[ 
             "isBook":false, 
             "typeId":0 
             ], 
            "productId":5,"productViews":0 
            ], 
            ["discount":0.0, 
            "orderDetailId":0, 
            "price":50000.0, 
            "quantity":1, 
            "shippingCharge":50.0, 
            "supplierId":0,"tax":0.0, 
            "type":[ 
             "isBook":false, 
             "typeId":0 
             ], 
            "productId":8, 
            "productViews":0 
            ], 
            ["discount":0.0, 
            "orderDetailId":0, 
            "price":2000.0, 
            "quantity":1, 
            "shippingCharge":50.0, 
            "supplierId":0,"tax":0.0, 
            "type":[ 
             "isBook":false, 
             "typeId":0 
             ], 
            "productId":9, 
            "productViews":0 
            ] 
           ], 
           "paymentTransactionId":"1215455638874521", 
           "state":"fyy", 
           "zip":"4525", 
           "countryId":23, 
           "orderId":0, 
           "orderTotal":82000.0, 
           "paymentMethodId":1, 
           "userId":0] 
関連する問題