首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >NSURLConnection : JSON文本未以数组或对象开头,并且未设置允许片段的选项

NSURLConnection : JSON文本未以数组或对象开头,并且未设置允许片段的选项
EN

Stack Overflow用户
提问于 2014-12-17 16:52:10
回答 3查看 45.6K关注 0票数 21

我从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中的所有解决方案,但都是从本质上说的。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27521547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档