let parameters = [
"par1":"create",
"comments":"Тестовый заказ",
"fio":"Данил Иванов Иванович",
"client":[
"user_id": "482",
"city_id": "1",
"phone": "+79181442810",
"address": "Пушкина 34"
],
"order_items": [
[
"id": "1932",
"quantity": "2",
"comment": "test"
],
[
"id": "1932",
"quantity": "3",
"comment": "test"
]
]
]
这是我的参数,请求Alamofire。
Manager.request(.POST, "http://buffet.softkb.ru/buffet/order/create", parameters: parameters, headers: ["Content-Type": "application/json", "X-Requested-With": "XMLHttpRequest"])
.responseSwiftyJSON({ (request, response, json, error) in
print("get")
print(json)
print(error)
if error == nil {
if json["msg_code"] != 0 {
self.showAlert("Ошибка", message: "\(json["msg_text"])", button: "ОК")
} else {
}
}
})
服务器必须接受类似的东西:
array (
'par1' => 'create',
'comments' => '',
'fio' => 'Афонина юлия Юрьевна ',
'client' =>
array (
'user_id' => '482',
'city_id' => '1',
'phone' => '+79529951385',
'address' => '1 микр общ 13 кв 13',
),
'order_items' =>
array (
0 =>
array (
'id' => '1932',
'quantity' => '2',
'comment' => '',
),
1 =>
array (
'id' => '2044',
'quantity' => '1',
'comment' => '',
),
2 =>
array (
'id' => '2154',
'quantity' => '1',
'comment' => '',
),
3 =>
array (
'id' => '2025',
'quantity' => '2',
'comment' => '',
),
),
但它接受了这个:
array (
'par1' => 'create',
'comments' => 'Тестовый заказ',
'fio' => 'Афонина Юлия Юрьевна',
'client' => '["user_id":482, "ctiy_id": 1, "phone": "+79181672810", "address": "пушкина 34"]',
'order_items' => '[["id": 1932, "quantity":3, "comment":""],["id": 1932, "quantity":3, "comment":""]]',
),
我想,当我按数组填充数组或其他内容时,必须有所不同 我怎样才能解决这个问题?非常感谢您的帮助