How can I parse my JSON file stored in the application?
These are in my JSON file contents:
[{"number":"01001","lieu":"paris"}{"number":"01002","lieu":"Dresden"}]
I’ve tried the following code:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@"json"];
//création d'un string avec le contenu du JSON
NSString *myJSON = [[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL];
//Parsage du JSON à l'aide du framework importé
NSDictionary *json = [myJSON JSONValue];
NSArray *statuses = [json objectForKey:@"number"];
for (NSDictionary *status in statuses)
{
NSLog(@"%@ ", [status objectForKey:@"lieu"]);
}