开发者社区 问答 正文

IOS SBJson解析

代码如下

  • (void)openIdRequest:(ASIHTTPRequest *)request
    {

     NSString *str = [[request.responseString componentsSeparatedByString:@"callback"] objectAtIndex:1]; 
      
     NSLog(@"==========>>>%@",str); 
      
     SBJSON *json = [[SBJSON alloc]init]; 
      
     NSError *error = nil; 
      
     NSArray *arry = [json objectWithString:str allowScalar:YES error:&error]; 
      
     NSLog(@"------>>>%@",arry); 
    

}

输出:

2013-11-16 21:38:17.161 TestSinna[2935:c07] ==========>>>( {"client_id":"1101107098","openid":"79CA2E49845A8CEA5B901ABFB477DAE3"} );
2013-11-16 21:38:17.161 TestSinna[2935:c07] ------>>>(null)

问题,如何才能使数据装入数组中??????

展开
收起
杨冬芳 2016-06-30 15:40:55 2017 分享 版权
1 条回答
写回答
取消 提交回答
  • IT从业

    可以使用NSDictionary,键值对应加载和解析。

    2019-07-17 19:49:31
    赞同 展开评论