我正在从我的Swift应用程序中使用Alamofire进行API调用,并且成功进行了调用,但是,我遇到了以下错误。
Error: Optional(Alamofire.AFError.responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain=NSCocoaErrorDomain Code=3840 "Unable to convert data to string around character 2643." UserInfo={NSDebugDescription=Unable to convert data to string around character 2643.})))
随后是API调用
Alamofire.request(Constants.urlString)
.responseJSON { response in
guard let json = response.result.value as? [String: Any] else {
print("didn't get todo object as JSON from API")
print("Error: \(response.result.error)")
return
}
print(json)
甚至,我也检查了Postman中的网址,并显示了该网址是否有效。我也检查了jsonlint.com的响应,甚至还显示了有效的json。
有人可以建议我如何解决此问题吗?