响应字符串显示,您的请求被禁止,因为它会导致循环。”;“检测到循环”;答复(400) JSON
代码:响应字符串显示,您的请求被禁止,因为它会导致循环。”;“检测到循环”;答复(400) JSON,json,swift3,xcode8,ios10,Json,Swift3,Xcode8,Ios10,代码: [ { "userName”:”abcd”, "phoneNumber”:”987456321”, "latitude":12.911757, "longitude":80.2162277, "speed":0, "updatedOn":"Dec 20, 2016 2:12:56 AM", "userMessage":"Hello" }, { "userName”:”EFGH”
[
{
"userName”:”abcd”,
"phoneNumber”:”987456321”,
"latitude":12.911757,
"longitude":80.2162277,
"speed":0,
"updatedOn":"Dec 20, 2016 2:12:56 AM",
"userMessage":"Hello"
},
{
"userName”:”EFGH”,
"phoneNumber”:”987546123”,
"latitude":12.911757,
"longitude":80.2162277,
"speed":0,
"updatedOn":"Dec 20, 2016 7:58:49 AM",
"userMessage":"Hello"
}
]
let responseString:String=NSString(数据:data!,编码:String.encoding.utf8.rawValue)!作为字符串
打印(应答)
让myJSON=try JSONSerialization.jsonObject(带:data!,选项:.allowFragments)为!排列
myJSON中的字典
{
if(UserDefaults.standard.value(forKey:“phoneNumber”)as!String)!=(dictionary[“phoneNumber”]as!String)
{
让uname=dictionary[“userName”]作为!字符串
让phoneNo=dictionary[“phoneNumber”]作为!字符串
设lat=字典[“纬度”]为!双精度
让long=字典[“经度”]为!双精度
设speed=dictionary[“speed”]为!Int
//让时间=字典[“updatedOn”]作为!字符串
让userMessage=dictionary[“userMessage”]作为!字符串
self.array\u usermsg.append(userMessage)
let marker=GMSMarker()
marker.position=CLLocationCoordination2DMAKE(横向、纵向)
marker.icon=UIImage(名为:“car.jpg”)
marker.map=self.mapViewFist
}
}
响应字符串显示:“您的请求被禁止,因为它会导致循环”。“检测到循环”响应(400)。我刚刚遇到这个问题。我采取了以下步骤解决了这个问题(在我惊慌失措了一段时间之后):
这应该可以解决这个问题。至少对我来说是这样。这是一个很好的错误消息、JSON块和代码块。你也有问题要问他们吗?检查一下提示:仔细看一下引号。这真的是JSON吗?还是你编辑的?我问这个问题的原因是我注意到你的一些引号是“智能”引号(开放或结束引号)。我想知道你的JSON是否被破坏了,或者这是否发生在你编辑问题的时候……还有,你知道这就是你的JSON的样子吗?或者这就是你认为它应该看起来的样子。同样,这个JSON是真正的内容吗(即你是否
让responseString=String(数据:data!,编码:.utf8)
,然后打印出responseString
)?这是有效的JSON格式。我敢肯定。Rob I checked response string,Cycle Detected Description:您的请求被禁止,因为它会导致循环。“Cycle Detected”响应(400)-->\n\n\0“今天已完成此操作,但我的代理已直接在“邮递员”中设置。
let responseString:String = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)! as String
print(responseString)
let myJSON = try JSONSerialization.jsonObject(with: data!, options:.allowFragments) as! Array<Dictionary<String, Any>>
for dictionary in myJSON
{
if (UserDefaults.standard.value(forKey: "phoneNumber") as! String) != (dictionary["phoneNumber"] as! String)
{
let uname = dictionary["userName"] as! String
let phoneNo = dictionary["phoneNumber"] as! String
let lat = dictionary["latitude"] as! Double
let long = dictionary["longitude"] as! Double
let speed = dictionary["speed"] as! Int
//let time = dictionary["updatedOn"] as! String
let userMessage = dictionary["userMessage"] as! String
self.array_usermsg.append(userMessage)
let marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(lat, long)
marker.icon = UIImage(named: "car.jpg")
marker.map = self.mapViewFist
}
}