I am new to Objective-C, and JSON so I am confused on how to do this. I have looked up tutorials, and made sure my JSON is valid.
I have a SQL server database that I am trying to access by parsing JSON. I have checked to make sure my JSON is valid. Whenever I attempt to parse the JSON is Objective-C, however, it always returns null.
Here is my JSON:
[ { "ID": 1, "Username": "Cray", "Password": "fake", "Active": 0, "LastLogin": null } ] Here is my Objective-C code:
NSString *urlString = [NSString stringWithFormat:@"http://quacknasty.com/service.php"]; NSURL *url = [NSURL URLWithString:urlString]; NSData *data = [NSData dataWithContentsOfURL:url]; NSError *error; NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; NSLog(@"test%@", json); json always returns null when I do the NSLog
NSLog(@"JSON error = %@", error);[]is absolutely valid JSON! He did change his server code since yesterday, see my answer, there is the original API response. @user3871044: Did my answer solve your problems? Then please remember to accept :)