I am trying to parse a json string requested from an api located at: http://www.physics.leidenuniv.nl/json/news.php
However, i am having trouble parsing this json.
I get the following error:
Unexpected end of file during string parse
I have looked for hours, but I can not find an answer to this problem.
My code snippet:
In my viewDidLoad:
NSURLRequest *request = [NSURLRequest requestWithURL:
[NSURL URLWithString:@"http://www.physics.leidenuniv.nl/json/news.php"]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
The delegate:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSMutableData *responseData = [[NSMutableData alloc] init];
[responseData appendData:data];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSError *e = nil;
NSData *jsonData = [responseString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:jsonData options: NSJSONReadingMutableContainers error: &e];
}
Anybody know an answer to this problem so i can parse the json data?