Could you please forgive me for eventual mistakes i can make asking this question me it’s my first one here.
After reading several topics on this website, like this one first i’ll try to use the describe methods but it still doesn’t work @ all 🙁
My .json file looks like this
{ "speakers" :
[
{
"name":"Value",
"picture": "URL VALUE",
"business":"VALUE",
"desc":"VALUE",
"twitter": "URL VALUE"
}
{
...
}
]
}
So this is my reasoning :
I firstly have a dictionary which contains speaker attribute
This one contains an array, field by some dictionnaries within “name”, “business”,… attr.
So, this is my obj-C code :
NSString *URLStr = @"URLofMyJsonFile";
NSURLRequest *JSONRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithString:URLStr ]]];
NSData *JSONData = [NSURLConnection sendSynchronousRequest:JSONRequest returningResponse:nil error:nil];
NSError *parsingError = nil;
NSDictionary *speakerDictionnary = [NSJSONSerialization JSONObjectWithData:JSONData options:0 error:&parsingError];
NSArray *speakersArray = [speakerDictionnary objectForKey:@"news"];
for (NSDictionary *oneSpeaker in speakersArray) {
NSLog(@"The speakers's name is %@", [oneSpeaker objectForKey:@"name"]);
NSLog(@"The speakers's business is %@", [oneSpeaker objectForKey:@"business"]);
NSLog(@"The speakers's desc is %@", [oneSpeaker objectForKey:@"desc"]);
}
EDIT : I remplace the right URL of my Script with Dummy
Your JSON isn’t valid, there needs to be a comma between the individual speaker dictionaries.