Error: Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character如何使用下面提到的代码在Swift中序列化JSON请求?
func FAQ(token: String){
let urlString = BaseURL + "faq?token=" + token
request(.GET, urlString).responseJSON(options: NSJSONReadingOptions.AllowFragments){(json) -> Void in
if json.result.error != nil{
NSNotificationCenter.defaultCenter().postNotificationName(NotifRequestError.FAQ.rawValue, object: json.result.error, userInfo: nil)
print(json.result.error)
return
}
let responseDict = NSMutableDictionary(dictionary: json.result.value as! NSDictionary)
print(responseDict)
NSNotificationCenter.defaultCenter().postNotificationName(NotifRequestSuccess.FAQ.rawValue, object: self, userInfo: ["data": responseDict])
}
}
您的JSON是无效 – Gruntcakes
这是我已经张贴在这里它的原因,该代码工作对于其他apis,但我在几个API调用中遇到了这个问题。 –
如果你知道json是无效的,那么你的标题完全不适合实际的问题。 – Gruntcakes