[
{
"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"
}
]
CODE :
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
}
}
响应字符串显示:“您的请求被禁止,因为它会导致循环”。 “循环检测”响应(400)。
答案 0 :(得分:0)
我只是有这个问题。我采取了以下步骤解决了这个问题(在我吓了一跳之后):
这应该可以解决问题。至少对我有用。