I'm trying to parse a JSON string from a web service. The string that is coming in looks like this:
{
"Faculty_Members": [
{
"ID": 3377,
"First_Name": "John",
"Last_Name": "Doe"
}
]
}
My IOS Code looks like this:
NSURL *jsonUrl = [NSURL URLWithString:@"http://website/Service1.svc/Names"];
NSError *error = nil;
NSData *jsonData = [NSData dataWithContentsOfURL:jsonUrl options:kNilOptions error:&error];
NSMutableDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:&error];
NSLog(@"%@",jsonResponse);
//parse out the json data
if([NSJSONSerialization isValidJSONObject:jsonResponse])
{
NSLog(@"YEP");
}else{
NSLog(@"NOPE");
}
The log will show the correct JSON data, but I keep getting "NOPE" on the isValidJsonObject.
The web service is sending the data back as datatype "string". Does that make a difference? If so, what datatype should i send it back?
Any ideas will be greatly appreciated!