Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
224 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...