Created
February 23, 2012 11:23
-
-
Save pratikshabhisikar/1892445 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *jsonString = @"{\ | |
\"posts\" : [\ | |
{\ | |
\"post\" : {\ | |
\"description\" : \"The latest news from the Joomla! Team\",\ | |
\"id\" : \"1\",\ | |
\"title\" : \"Latest\"\ | |
}\ | |
},\ | |
{\ | |
\"post\" : {\ | |
\"description\" : \"A selection of links that are all related to the Joomla! Project.\",\ | |
\"id\" : \"2\",\ | |
\"title\" : \"Joomla! Specific Links\",\ | |
}\ | |
}\ | |
]\ | |
}"; | |
//NSLog(@"%@", jsonString); | |
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; | |
NSError *error = nil; | |
NSDictionary *jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error]; | |
if (jsonDictionary) { | |
//NSLog(@"%@", jsonDictionary); | |
NSArray *posts = [jsonDictionary objectForKey:@"posts"]; | |
for (NSDictionary *aPost in posts) { | |
NSLog(@"%@", aPost); | |
} | |
}else { | |
if (error) { | |
NSLog(@"Error %@ encountered while creating JSON Dictionary", [error localizedDescription]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment