i need to parse the Apple JSON but i have a little problem. I’m now doing this:
The problem is here:
- (void)fetchedData:(NSData *)responseData {
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData
options:kNilOptions
error:&error];
NSNumber *resultCount = [json objectForKey:@"resultCount"];
NSLog(@"%i", [resultCount intValue]);
NSArray * AppStoreUrlParse = [json objectForKey:@"results"];
NSDictionary* StoreParse = [AppStoreUrlParse objectAtIndex:0];
NSLog(@"%@", [json objectForKey:@"price"]);
}
On this line:
NSLog(@"%i", [resultCount intValue]);
The NSlog is returing: 1 like in the JSON ( http://itunes.apple.com/lookup?id=387633954)
But on this line
NSLog(@"%@", [json objectForKey:@"price"]);
The NSLOG returns (Null)
does anyone know how i can get the price from the json?
It seems that ‘price’ is part of a dictionary that is the first item in the ‘results’ array.
Can you try
This would get the value of the key ‘price’ in the first element of the ‘results’ array of your JSON.
EDIT
Actually, rereading your code, you are already getting the first element of the array in this line:
So all you need to do is change
jsonbyStoreParsein your NSLog: