afnetworking json解析出错

解决方法1

    AFURLResponseSerialization.m
258行修改 responseString = [responseString stringByReplacingOccurrencesOfString:@"\r\n" withString:@""];
responseString = [responseString stringByReplacingOccurrencesOfString:@"\n" withString:@""];
responseString = [responseString stringByReplacingOccurrencesOfString:@"\t" withString:@""];
data = [responseString dataUsingEncoding:NSUTF8StringEncoding];

解决方法2

数据请求失败
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x9b7eba0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
解决:
AFNetWorking的JSON解析默认库是使用的AFJSONRequestOperation模式,只支持text/json,application/json,text/javascript,所以如果出现code=-1016错误则说明当前的JSON解析模式是text/html,所以要加上这段代码:

最新文章

  1. POJ 3667 Hotel(线段树 区间合并)
  2. 点击div折叠
  3. [Android]AndroidBucket增加碎片SubLayout功能及AISubLayout的注解支持
  4. 常用SQL语句优化技巧
  5. 您需要来自administrators的权限才能对此文件进行更改
  6. cocos2d-x for js 继承的写法
  7. Linux串口调试
  8. Cinder-1 TinderBox
  9. sockaddr结构体
  10. Kubernetes初探[1]:部署你的第一个ASP.NET Core应用到k8s集群
  11. 【SQL】ROW_NUMBER() OVER(partition by 分组列 order by 排序列)用法详解+经典实例
  12. SSM 框架 整合<SpringMVC+Spring+MyBatis>
  13. ionic使用cordova插件中的Screenshot截图分享功能
  14. Numpy:索引与切片
  15. Godaddy新手教程
  16. 使用eclipse在linux下开发C/C++
  17. js 时间日期函数小结
  18. 【最简单】不用ps也可以批量转换图片格式
  19. jquery 图片预加载
  20. 报错 ERROR in static/js/vendor.b3f56e9e0cd56988d890.js from UglifyJs

热门文章

  1. 前端基础 之css
  2. http协议之基础概念篇(1)
  3. 洛谷 - P4449 - 于神之怒加强版 - 莫比乌斯反演
  4. Unity3D asset bundle 格式简析
  5. 2014-6-28 NOIP模拟赛
  6. SpringBoot2.0基础案例(01):环境搭建和RestFul风格接口
  7. shell学习(3)- grep
  8. JDBC | 查询表数据行数
  9. Tinghua Data Mining 8
  10. 牛客寒假6-E.海啸