JSON
我已经以我已成功存储的格式检索了以下响应表单服务器NSDictionary
。
{
"@companyName" = "MobileAPPSDeveloper";
"@generatedDate" = "8/6/13 2:41 AM";
"@version" = "1.0";
application = (
{
"@apiKey" = 234FXPQB36GHFF2334H;
"@createdDate" = "2013-03-01";
"@name" = FirstApp;
"@platform" = iPhone;
},
{
"@apiKey" = 3PF9WDY234546234M3Z;
"@createdDate" = "2013-02-01";
"@name" = SecondAPP;
"@platform" = iPhone;
},
{
"@apiKey" = NXGQXM2347Y23234Q4;
"@createdDate" = "2013-05-22";
"@name" = ThirdApp;
"@platform" = Android;
}
);
}
这是我用过的方法。
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[self convertDataIntoDictionary:responseData];
}
-(void)convertDataIntoDictionary:(NSData*)data{
NSDictionary *dictionary;
if (data.length>0) {
NSError *parsingDataError;
dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&parsingDataError];
if (parsingDataError) {
// [ErrorAlert showError:parsingDataError];
NSString *recievedString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"Data Conversion Error When Parsing: %@", recievedString);
}
}
NSLog(@"Data back from server\n %@",dictionary);
NSArray *applicationDetails = dictionary[@"application"];
}
我不能更进一步吗?
我想在数组中获取所有应用程序的名称。
任何帮助将不胜感激。