错误: Cocoa error 3840 (使用AFNetworking报错)

来源:互联网 发布:域名备案微信公众号 编辑:程序博客网 时间:2024/05/16 12:23

错误

在使用AFNetworking的POST方式连接WEB API时,报错:
“The operation couldn’t e completed. (Cocoa error 3840).”

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=0x1667f670 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

解决方案

这是一个JSON解析错误,一般来说出现这个错误很可能是因为你WEB API返回的JSON数据格式不正确造成的。

所以,要先确认WEB API的返回值是否为正确有效的JSON格式。可以用下面的在线JSON校验工具来检查。

推荐文章: 网络请求及各类错误代码含义总结(Errors Code)

0 0
原创粉丝点击