0
對不起,如果這是一個經常性問題,但我找不到任何好的答案。AFNetworking和JSON參數
使用AFNetworking和SwiftyJSON。
我需要這樣做:
let locationJArray = JSON(myLocationArray)
let params = [
"deviceID" : deviceID
,"deviceAPIKey" : deviceAPIKey
,"location" : locationJArray
]
locationJArray內容:
[
{
"theDirection" : -1,
"latitude" : -22.90354,
"longitude" : -43.20959,
"theAccuracy" : 5,
"theSpeed" : -1
}
]
錯誤:
當我試圖通過locationJArray到PARAMS值Type of expression is ambiguous without more context
。
相反,使用myLocationArray直接參數值作品,但數據完全無法被api讀取。
PARAMS內容使用myLocationArray:
["deviceID": 68, "location": (
{
latitude = "-22.90354";
longitude = "-43.20959";
theAccuracy = 5;
theDirection = "-1";
theSpeed = "-1";
}
), "deviceAPIKey": a4465be43ec2b4c3baa50d2ca5ee2be8]
我怎麼能傳遞一個參數值作爲JSON?