I’m trying to access “node” node for this JSON message:
{
"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": ""
}
}
]
}
With this code:
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSDictionary *results = [responseString JSONValue];
NSDictionary *nodes = [results objectForKey:@"nodes"];
results dictionary has 1 key result. nodes dictionary has 10 keys result. But when I try to access for node with all of this options, I got no results:
NSString *node = [nodes valueForKey:@"node"];
NSArray *nodeArray = [nodes objectForKey:@"node"];
NSDictionary *nodeDic = [nodes objectForKey:@"node"];
Many thanks
The object you retrieve with
is not a dictionary, it is an array of dictionaries, each with one entry with the key “node”. To get the first node: