Reputation: 317
I get back a json of structure like
{ ResultCount =7; ResultLimit=30; ResultList=({ AlbumId=111;ArtistId=203},{AlbumId=112;ArtistId=203}); Status=0}
The ResultList is an array. How can I get the AlbumId and ArtistId in an NSArray?
Upvotes: 0
Views: 1276
Reputation: 9390
Hi happy_iphone_developer,
ResultList is not a Array and it's NSDictionary.
NSString *urlDataString = [[NSString alloc] initWithData:RecievedData encoding:NSUTF8StringEncoding];
parser = [[SBJSON alloc] init];
NSError *error = nil;
NSArray *resultArray = [parser objectWithString:urlDataString error:&error];
NSString *extractString = [[resultArray valueForKey:@"ResultList"] valueForKey:@"AlbumId"];
Whatever you want to extract, use this way to extract the particular data.
Thanks.
Upvotes: 2
Reputation: 8804
are you wanting to make good json ? then,
{ ResultCount:7, ResultLimit:30, ResultList:[{ AlbumId:111,ArtistId:203},{AlbumId:112,ArtistId:203}]}
or you want to parse in iPhone then
http://code.google.com/p/json-framework
is good framework
Upvotes: 1