happy_iphone_developer
happy_iphone_developer

Reputation: 317

json string into key value NSArray iPhone

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

Answers (4)

Pugalmuni
Pugalmuni

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

Mujah Maskey
Mujah Maskey

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

Michaël
Michaël

Reputation: 6734

The ResultList is not a NSArray, it's a NSDictionnary.

Upvotes: 0

hennes
hennes

Reputation: 9342

Just use a JSON framework like this and you're set.

Upvotes: 0

Related Questions