JSON hosted in Google Drive is not being processed
I am trying to parse a json file hosted in my google drive. I am using the following code:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL* url = [NSURL URLWithString:@"https://docs.google.com/file/d/0B3CRs9y562F3a0VXTXNaekNiSXM/edit?usp=sharing"];
NSURLRequest* request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if (!error) {
NSDictionary* jsonDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(@"jsonDictionary \n%@", jsonDictionary);
}
}];
}
I checked the url and draw it either with code or without access from google drive. If the code is bad, I cannot see where it is. If the .json file cannot be parsed from Google Drive, where can I post access to this content? Does it have to be on my own domain? I looked at hosting on Google Code but definitely not what I need with version control and that's it.
source to share
When I load this url, I get nothing. other options might be to put the document behind the node.js api and do a redirect from there, or revert it against AWS S3 and make a call from there. I don't think the google drive allows in-place parsing, except that it loads all the text first. I think putting it on a service like heroku with api will serve you best.
source to share
your json file format is not proper. Try this code you will get error what is wrong in
your json File
NSURL* url = [NSURL URLWithString:@"https://docs.google.com/file/d/0B3CRs9y562F3a0VXTXNaekNiSXM/edit?usp=sharing"];
NSURLRequest* request = [NSURLRequest requestWithURL:url];
NSData *response = [NSURLConnection sendSynchronousRequest:request
returningResponse:nil error:nil];
NSError *jsonParsingError = nil;
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:response
options:0 error:&jsonParsingError];
if (!jsonArray) {
NSLog(@"Error parsing JSON: %@", [jsonParsingError description]);
} else {
for(NSDictionary *item in jsonArray) {
NSLog(@"Item: %@", item);
}
}
source to share