我正在尝试通过alamofire发送参数,并且在参数中有重复的密钥。我需要传递该密钥,但是每当尝试它时,都会弹出错误消息。
let param : [String: Any] = ["contactPerson": [ "email":[ "email": contactemail], "markedForSendingRezInfo": false,"preferred": false,"shareMarketInd": false], "personName": ["givenName": contactname,"shareMarketInd": false,"surname": contactlastname],"phoneNumber":["countryCode": contactcountrycode,"markedForSendingRezInfo": false,"preferred": false,"shareMarketInd": false,"subscriberNumber": contactphone],"shareMarketInd": false,"useForInvoicing": false,"curr":"USD","flight1" : selectedflightjson,"flight1" : selectedflightjsonRM,"passengers":[passengerparameterarray],"pwd": password,"requestPurpose": "MODIFY_PERMANENTLY_AND_CALC","unm": username
]
这是我的代码,“ email”:[“ email” ..两次。我如何解决它?我在StackOverflow中提出了几个问题,但他们都在谈论从服务器获取这种响应。但是在这里,我试图将其发送到服务器。
那我该如何解决呢?
{
"contactPerson": {
"email": {
"email": "a@gmail.com",
"markedForSendingRezInfo": false,
"preferred": false,
"shareMarketInd": false
},
"personName": {
"givenName": "v",
"shareMarketInd": false,
"surname": "j"
},
"phoneNumber": {
"countryCode": "1",
"markedForSendingRezInfo": false,
"preferred": false,
"shareMarketInd": false,
"subscriberNumber": "123456789"
},
"shareMarketInd": false,
"useForInvoicing": false
},
这是我json的一部分。另外[passengerparameterarray]也有相同的问题,如果我将[passengerparameterarray]隐瞒到json中并将其传递给此参数,是否可以使用?我已经将'selectedflightjson'作为Json传递了,因为这是一个肥皂api。
谢谢。
答案 0 :(得分:0)
您必须按以下方式管理对象:
let param : [String: Any] =
[
"contactPerson": [
"email": [
"email": contactemail,
"markedForSendingRezInfo": false,
"preferred": false,
"shareMarketInd": false
],
"personName": [
"givenName": contactname,
"shareMarketInd": false,
"surname": contactlastname
],
"phoneNumber": [
"countryCode": contactcountrycode,
"markedForSendingRezInfo": false,
"preferred": false,
"shareMarketInd": false,
"subscriberNumber": contactphone
],
"passengers": [
passengerparameterarray
],
"shareMarketInd": false,
"useForInvoicing": false,
"curr": "USD",
"flight1": selectedflightjson,
"flight2": selectedflightjsonRM,
"pwd": password,
"requestPurpose": "MODIFY_PERMANENTLY_AND_CALC",
"unm": username
]