ios – NSURLConnection:JSON文本没有从数组或对象开始,并且选项允许未设置片段

ios – NSURLConnection:JSON文本没有从数组或对象开始,并且选项允许未设置片段,第1张

概述我从NSURLConnection connectionDidFinishLoading得到以下错误 “(Cocoa错误3840.)”(JSON文本没有从数组对象开始,并且选项允许片段未设置.)UserInfo = 0x7b71dbb0 {NSDebugDescription = JSON文本没有以数组或对象开头并允许片段未设置的选项. 我使用以下代码: -(void)connectionDid 我从NSURLConnection connectionDIDFinishLoading得到以下错误

“(Cocoa错误3840.)”(JsON文本没有从数组或对象开始,并且选项允许片段未设置.)UserInfo = 0x7b71dbb0 {NSDeBUGDescription = JsON文本没有以数组或对象开头并允许片段未设置的选项.

我使用以下代码:

-(voID)connectionDIDFinishLoading:(NSURLConnection *)connection {    NSError *error;    ID Json = [NSJsONSerialization JsONObjectWithData:_urlData options:kNilOptions error:&error];    if (error) {        NSLog(@"Loading Error = %@",error);    }}

以下是我的Json回复:

{     "result":"success","details":[        {           "ID":"11531","user_name":"","fullname":"aa","email_address":"aa","user_type":"a","server":"","server_email":"","server_password":"","password":"0cc175b9c0f1b6a831c399e269772661","clean_password":"a","gender":"","ceo_name":"","ceo_picture":"","ceo_contact":"","ceo_contact_pic":"","company_name":"a","freight_company_name":"","freight_company_email":"","company_url":"11531","company_keyword":"","company_description":"","address":"","province":"","postal_code":"","phone_number":"","fax_number":"","website":"","city":"","b_category":"","main_products":"","cellphone":"a","country":"0","states":"","company_status":"1","joindate":"0","varificationcode":"","activation_status":"1","new_email":"","email_activation_status":"","facebook_url":"","twitter_url":"","company_update_status":"0","last_access_date":"0000-00-00","ip_address":"","ip_block":"0","user_ID":null,"company_ID":null,"vIDeo_url":"","oauth_uID":"","oauth_provIDer":"","get_color":"","comp_name_size":"13","member_type":"","mark_status":"1","ip_address_intension":"","fbID":"","twitterID":"","profile_picture":"","device_token":""      }   ]}

我已经尝试了stackOverflow中的所有解决方案,但是静态.

解决方法 将选项值设置为NSJsONReadingallowFragments而不是kNilOptions
我测试了您的JsON在本地文件中

ID Json = [NSJsONSerialization JsONObjectWithData:contentOfLocalfile                                                options:NSJsONReadingallowFragments                                                  error:&deserializingError];
总结

以上是内存溢出为你收集整理的ios – NSURLConnection:JSON文本没有从数组或对象开始,并且选项允许未设置片段全部内容,希望文章能够帮你解决ios – NSURLConnection:JSON文本没有从数组或对象开始,并且选项允许未设置片段所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1065507.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存