jsonkit
jsonkit //#define kDoubanUrl @"http://douban.fm/j/mine/playlist?type=n&h=&channel=0&from=mainsite&r=4941e23d79" //jsonkit NSString* strUrl=kDoubanUrl; //it return json format string
NSURL *url=[NSURL URLWithString:strUrl]; NSMutableURLRequest *request=[[NSMutableURLRequest alloc] initWithURL:url]; NSError *err=nil; NSData *jsonData=[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&err];
NSDictionary *resultsDictionary = [jsonData objectFromJSONData]; NSLog(@"resultsDictionary=%@ n %@",resultsDictionary,[resultsDictionary objectForKey:@"r"]); NSMutableArray *songs = [resultsDictionary objectForKey:@"song"]; NSLog(@" songs %@ n 0000000000 %@",songs,[songs objectAtIndex:0]);
for (int i=0; i<[songs count]; i++) { NSDictionary *dic = [songs objectAtIndex:i ]; //NSLog(@"dic=%@",dic );
NSString *jsonTextStr = @"歌:"; jsonTextStr = [jsonTextStr stringByAppendingString:[dic objectForKey:@"title"]]; jsonTextStr = [jsonTextStr stringByAppendingString:@"n"]; jsonTextStr = [jsonTextStr stringByAppendingString:[dic objectForKey:@"url"]]; NSLog(@"信息:%@",jsonTextStr); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |