0
이 json을 CMS에서 반환했으며이를 따로 구분하고 다른 값을 사용해야합니다.Objective C에서 JSON 구문 분석
{"nodes":
[{"node":
{"created":"14012013165204","lastupdated":"03042013133901","type":"News"}
}]
}
나는 JSONKit 프레임 워크를 사용하고 여기에 내 코드입니다 : 나는 결과의 다음 부분을 얻는 방법을 모르는
NSString* theURL = [NSString stringWithFormat:@"http://testserver.com/content_lastupdate.json"];
NSError* err = nil;
NSURLResponse* response = nil;
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] init];
NSURL*URL = [NSURL URLWithString:theURL];
[request setURL:URL];
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
[request setTimeoutInterval:30];
NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSString *output = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSDictionary *resultsDictionary = [output objectFromJSONString];
NSLog([NSString stringWithFormat:(@"Response: %@"), output]);
NSDictionary *nodes = [resultsDictionary objectForKey:@"nodes"];
NSObject *node = [nodes objectForKey:@"node"];
은. 노드 키가 있지만 다음 노드는 발견되지 않습니다. 어떤 기본 아이디어를 내가 여기에서 놓치고 있니?
) JSON을 읽는 법을 배우십시오. 매우 간단합니다. JSON.org를 확인하십시오. B) NSLog를 사용하십시오. 그것은 디코딩 된 JSON 객체를 JSON과 유사한 구문으로 출력하지만 ('()'대신'() '이 사용됨) 각 레이어를 "껍질"벗겨 낼 때 구조를 볼 수 있습니다. –