我有一个JSON字符串格式
{
abstract = "Today P.M of India Mr. Narender Modi visited for the eve of Agarasen njayanti
n";
created = 1444733102;
imgUrl = "";
nid = 12;
title = "Latest news";
}
我想转换为NSDictionary
NSError *jsonError;
NSData *objectData = [[[tableDataArray objectAtIndex:indexPath.row]objectForKey:@"NewsValue"] dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:objectData options:NSJSONReadingMutableContainers error:&jsonError];
NSLog(@"%@",json);
They Give response is Null Please Help.
这已经是字典格式的Json数据了。
所以你不需要转换。只检索数据。
NSString * abstract = [Dic valueForKey:@"abstract"];
请在代码下面使用
NSData *objectData = [[[tableDataArray objectAtIndex:indexPath.row]objectForKey:@"NewsValue"]NSString * strresponse = [[NSString alloc] objectData encoding:NSUTF8StringEncoding];
NSMutableDictionary *dictResponse = [NSJSONSerialization JSONObjectWithData:[strResponce dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableLeaves error:&error];
if([dictResponse isKindOfClass:[NSMutableDictionary class]]) {
NSString * abstractStr = [dictResponse valueForKey:@"abstract"];
}