我正在尝试发出API请求以获取API响应我正在获取所有元素,但是我面临括号问题,我想在{}中使用整个响应和“ order_devices”键,但我在[大括号。
the array in which i am passing value,
var popUpArray :[[String:AnyObject]] = []
然后在btn上单击我将值保存在字典中
@IBAction函数btnSave(_发件人:任意){
let popupDict = (["quantity": Int(txtEnterQuantity.text!), "name": lblDeviceName.text,"id": deviceDict["id"], "region":1, "system_integrated":1 ])as! [String:AnyObject]
,然后传递与参数相同的字典值
let passDict = [
"dealer_id":dropDownId!,
"client_id":dropDownId!,
"distributor_id":searchBarId!,
"emp_id":UserId,
"comments":CommentKey!,
"accepted_by":0,
"valid_from":strDate!,
"valid_upto": 0,
"order_devices":popupDict
] as [String : Any]
if Reachability.isConnectedToNetwork() {
showActivityIndicator()
Alamofire.request("http://13.232.230.41/IAC_CRM/public/api/createOrder", method: .post, parameters: passDict, encoding: JSONEncoding.default, headers: [:])
.responseJSON { (response) in
我正在收到此回复,
[ “ comments”:“ demo”, “ dealer_id”:3, “ valid_from”:“ 6-3-2019”, “ distributor_id”:72, “ client_id”:3, “ accepted_by”:0, “ emp_id”:33, “ valid_upto”:0 “ order_devices”: [
[ “ id”:1 “数量”:10, “区域”:1, “ system_integrated”:1 ] , [ “ id”:2 “数量”:12 “区域”:1, “ system_integrated”:1 ] ] ]
我想要这个回复,
{“ dealer_id”:“ 1”,“ client_id”:“ 2”,“ distributor_id”:“ 2”, “ emp_id”:“ 1”,“ comments”:“ IAC测试设备注释”,“ accepted_by”:0, “ valid_from”:“ 2019-01-24”,“ valid_upto”:“ 1”,“ order_devices”:[ { “ device_id”:“ 1”, “数量”:“ 1”,“区域”:1,“系统集成”:1 } , { “ device_id”:“ 2”, “数量”:“ 1” “区域”:1, “ system_integrated”:1 } ]}
表示我想要整个响应,并在“花括号” {}中输入“ order_devices”键。
答案 0 :(得分:1)
请求或响应没有任何问题,您正在获得响应,您的API返回了什么,您应该请后端开发人员或Api Provider以您要求的形式给您答复,我的意思是正确的格式数组。