[英]Parsing JSON doubts - Objective C
I'm trying to parse this JSOn with multiple entries of "node" tag: 我正在尝试使用“ node”标签的多个条目来解析此JSOn:
{
"nodes": [
{
"node": {
"title": "Jornada del Fútbol Profesional contra el hambre",
"description": "
"image": ",
"fecha": ,
"nid": ",
"noticia_relacionada_1_path": ,
"noticia_relacionada_2_path": ,
"image_small_2":
}
}
]
}
Here is the code: 这是代码:
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
//data =nil;
NSDictionary *results = [responseString JSONValue];
NSArray *noticias = [results objectForKey:@"node"];
self.noticiasArray = [[NSMutableArray alloc] init];
for (int i = 0; i < [noticias count]; i++) {
news *noticia = [[news alloc] initWithDictionary:[noticias objectAtIndex:i]];
[self.noticiasArray addObject:noticia];
noticia=nil;
}
I got 10 elements in the notices array, but when I try to get the inner values in the initWithDictionary: they are always null. 我在notices数组中有10个元素,但是当我尝试在initWithDictionary中获取内部值时:它们始终为null。
Many thanks 非常感谢
Example: 例:
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
//data =nil;
NSDictionary *results = [responseString JSONValue];
NSDictionary *noticias = [results objectForKey:@"node"];
news *noticia = [[news alloc] init];
noticia.title = [noticias objectForKey:@"title"];
// do the same for the rest of the variables
[self.noticiasArray addObject:noticia];
noticia=nil;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.