美文网首页
AF解析json的时候报错:Error Domain=NSCoc

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

作者: Louis_dm | 来源:发表于2017-06-18 01:12 被阅读53次

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

解决方案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

相关文章

网友评论

      本文标题:AF解析json的时候报错:Error Domain=NSCoc

      本文链接:https://www.haomeiwen.com/subject/inxiqxtx.html