I have used this method,
NSDictionary *jsonObject=[NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:nil]; NSLog(@"jsonObject is %@",jsonObject);
It's printing "jsonObject is null".
Is there any problem with "error:nil".
I am not using any url or connection methods.
I have a json file and I want to display it in a table.
Please Try the following Code.
NSError* error; NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error]; NSArray* latestLoans = [json objectForKey:@"loans"]; NSLog(@"loans: %@", latestLoans);
Just in case anyone is here to see swift code:
NSData to NSDictionary
let dictionary:NSDictionary = NSKeyedUnarchiver.unarchiveObjectWithData(jsonData)! as NSDictionary
NSData to NSString
let resstr = NSString(data: res, encoding: NSUTF8StringEncoding)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With