AF解析json的时候报错:Error Domain=NSCoc

2017-06-18  本文已影响53人  Louis_dm

问题产生原因:服务器返回的字符串里面有换行符

解决方案1:服务器修改

解决方案2:代码解决

一.self.manager.responseSerializer = [AFHTTPResponseSerializer serializer];

二.导入jsonKit 项目可能报错 解决方案:http://blog.csdn.net/ios_wq/article/details/51285953

三:修改解析代码

NSError* e = nil;

NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:&e];

id result = [NSJSONSerialization JSONObjectWithData:strData options:0 error:&e];

if (e) {

e = nil;

dic = [responseObject objectFromJSONDataWithParseOptions:JKParseOptionLooseUnicode error:& e];  // use JSONKit

}

指导:http://www.jianshu.com/p/ed0f877af1e7

上一篇 下一篇

猜你喜欢

热点阅读