【发布时间】:2015-10-05 04:27:34
【问题描述】:
抱歉,如果这是一个反复出现的问题,但我找不到任何好的答案。
使用 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 传递给参数值时。
相反,直接将 myLocationArray 用于参数值是可行的,但 api 完全无法读取数据。
使用 myLocationArray 参数内容:
["deviceID": 68, "location": (
{
latitude = "-22.90354";
longitude = "-43.20959";
theAccuracy = 5;
theDirection = "-1";
theSpeed = "-1";
}
), "deviceAPIKey": a4465be43ec2b4c3baa50d2ca5ee2be8]
如何将参数值作为 JSON 发送?
【问题讨论】:
标签: ios json swift2 afnetworking-2 swifty-json