Created
April 3, 2012 10:46
-
-
Save hanksudo/2290974 to your computer and use it in GitHub Desktop.
Parse JSON from file.
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
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
NSString *path = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"json"]; | |
NSString *jsonString = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL]; | |
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; | |
NSDictionary *json = [self parseJSON:jsonData]; | |
} | |
- (NSMutableDictionary *)parseJSON:(NSData *)data | |
{ | |
NSError* jsonParsingError; | |
return [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonParsingError]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment