JSON parsing error

匿名 (未验证) 提交于 2019-12-03 01:27:01

问题:

I am trying to parse some JSON. I've passed a constant key value and a string - butI'm receivng 16 objects in the statuses array and 20 objects in ststuses1.

Are any of the parsing steps wrong?

I have included the code for the JSON parser.

Thanks in advance.

SBJSON *parser = [[SBJSON alloc] init];   NSString *urlString =[NSString stringWithFormat:@"http://api.shiki.com/api/serch?key=%@&q=%@",apiKey, string];  NSURL *url = [NSURL URLWithString:urlString];  NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url];     NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];     NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];   NSMutableArray *statuses = nil;  statuses = [[NSMutableArray alloc]init];  statuses = [parser objectWithString:json_string error:nil];   NSMutableArray *statuses0 = [[statuses valueForKey:@"offers"] valueForKey:@"offer"];  NSLog(@"Array Contents: %@", statuses0);

回答1:

I guess that's not the only syntax-error in your code...

Please define statuses and ststuses1. I can only see statuses (redefined 2 times) and statuses0. Also please post a sample of the json-data you're parsing so I can take a look at it.



转载请标明出处:JSON parsing error
文章来源: JSON parsing error
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!