ios json解析3840错误

来源:互联网 发布:java数组的逆序输出 编辑:程序博客网 时间:2024/06/08 03:37

日志如下:

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

后台数据不标准,检查后台数据是否错误,不是前端的事

完整代码如下:

    NSDictionary *parameters;    AlamofireRequest *fireRequest = [[AlamofireRequest alloc]init];    NSString *str = [fireRequest creatToken];    NSLog(@"%@",str);                    parameters =@{@"paraToken":str};    NSString *urlStr=[NSString stringWithFormat:@"http://130.55.225.204:81/smw/neeryProList"];                    AFHTTPSessionManager *manager =[AFHTTPSessionManager manager];                    manager.responseSerializer = [AFHTTPResponseSerializer serializer];                    [manager GET:urlStr parameters:parameters success:^(NSURLSessionDataTask *task, id responseObject)                     {                         NSJSONSerialization *json = [NSJSONSerialization JSONObjectWithData:responseObject options:nil error:nil];                         NSLog(@"!!!!!!!!!!!!!!!!!!!!!   %@",json);                         NSDictionary *dic = json;                         NSLog(@"%@",dic[@"productList"]);                         for (NSDictionary *d in dic[@"productList"]) {                             ProdectModel *model= [[ProdectModel alloc]init];                             model.productId = d[@"id"];                             model.name = d[@"n"];                             model.desc = d[@"d"];                             model.price = d[@"p"];                             model.coins = d[@"co"];                             [self.productModelArray addObject:model];                         }                         [self creatTableView];                     } failure:^(NSURLSessionDataTask *task, NSError *error)                     {                         NSLog(@"`````%@",error);                     }];
0 0
原创粉丝点击