Tag: sbjson

将JSON供稿转换为NSDictionary

JSON_CATEGORY_DATA_URL_STRING是我的供稿url,它可以正常返回: [ { "group":"For Sale", "code":"SSSS" }, { "group":"For Sale", "category":"Wanted", "code":"SWNT" } ] 我似乎无法得到一个很好的NSDictionary (或NSArray )以下代码: + (NSDictionary *)downloadJSON { NSDictionary *json_string; NSString *dataURL = [NSString stringWithFormat:@"%@", JSON_CATEGORY_DATA_URL_STRING]; NSLog(@"%@",dataURL); NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:dataURL]]; NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; json_string = [[[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding]autorelease]; NSDictionary *json_dict = (NSDictionary *)json_string; NSLog(@"json_dict\n%@",json_dict); […]