我想解析一些JSON。我传递了一个常量键值和一个字符串 - 但我在statuses
数组中接收了16个对象,在ststuses1
中接收了20个对象。JSON解析错误
是否有任何解析步骤错误?
我已经包含了JSON解析器的代码。
在此先感谢。
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);
这是否甚至编译?当它只声明一次时,你声明了3次“状态”。另外,我没有看到'statuses1'。 – 2010-08-11 18:18:22