<span style="font-size:14px;color:#3333ff;">error Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}</span>
3840是返回格式不能解析
具體原因呢
大部分服務器返回JSON
responseSerializer = AFJSONResponseSerializer
我們這么接受 本地AF 自動轉(zhuǎn)化為3840錯誤智润。但是根本不知道錯誤原因,
建議一下處理
responseSerializer = AFHTTPResponseSerializer
二進制數(shù)字自己處理
let jsonObj:AnyObject = try JSONSerialization.jsonObject(with: any as! Data, options: JSONSerialization.ReadingOptions.allowFragments) as AnyObject
catch{
if let str = String.init(data: any as! Data, encoding: String.Encoding.utf8){
}
}