Created
December 10, 2011 11:48
-
-
Save pratikshabhisikar/1454978 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
| #define SNAKE_AND_LADDER_DATA @"{\"data\":{\"1\":{\"snake\":[{\"from\":\"95\", \"to\":\"10\"}, {\"from\":\"75\", \"to\":\"20\"}], \"ladder\":[{\"from\":\"15\", \"to\":\"50\"}, {\"from\":\"25\", \"to\":\"90\"}]},\ | |
| \"2\":{\"snake\":[{\"from\":\"95\", \"to\":\"10\"}, {\"from\":\"75\", \"to\":\"20\"}], \"ladder\":[{\"from\":\"15\", \"to\":\"50\"}, {\"from\":\"25\", \"to\":\"90\"}]}\ | |
| }\ | |
| }" | |
| NSData *snakeLadderData = [SNAKE_AND_LADDER_DATA dataUsingEncoding:NSASCIIStringEncoding]; | |
| NSDictionary *rootDictionary = [NSJSONSerialization JSONObjectWithData:snakeLadderData options:NSJSONWritingPrettyPrinted error:nil]; | |
| NSLog(@"Dictionary: %@", rootDictionary); | |
| NSDictionary *snakeLadderDictionary = [rootDictionary objectForKey:@"data"]; | |
| NSLog(@"Info: %@", snakeLadderDictionary); | |
| NSDictionary *firstTheme = [snakeLadderDictionary objectForKey:@"1"]; | |
| NSDictionary *secondTheme = [snakeLadderDictionary objectForKey:@"2"]; | |
| NSLog(@"First Theme: %@", firstTheme); | |
| NSLog(@"Second Theme: %@", secondTheme); | |
| NSArray *firstThemeSnakes = [firstTheme objectForKey:@"snake"]; | |
| for (NSDictionary *aSnake in firstThemeSnakes) { | |
| NSLog(@"Snake From: %d", [[aSnake objectForKey:@"from"] integerValue]); | |
| NSLog(@"Snake To: %d", [[aSnake objectForKey:@"to"] integerValue]); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment