如何处理json输出中的responseString并对其进行解析

问题描述

|| 我正在使用以下代码,并且在JSON中获取响应字符串。我不知道如何解析它。如果要在JSON输出调用任何方法,下一步该怎么办 // 源代码
- (void)viewDidLoad
{
    [super viewDidLoad];

    dataWebService = [[NSMutableData data] retain];

    NSMutableuRLRequest *request = [[NSMutableuRLRequest requestWithURL:[NSURL URLWithString:@\"https://www.googleapis.com/customsearch/v1?key=AIzaSyDzl0Ozijg2C47iYfKgBWWkAbZE_wCJ-2U&cx=017576662512468239146:omuauf_lfve&q=lectures&callback=handleResponse\"]]retain];    

    NSURLConnection *myConnection = [NSURLConnection connectionWithRequest:request delegate:self];

    [myConnection start];    
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response 
{
    [dataWebService setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [dataWebService appendData:data];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{
    Nsstring *responseString = [[Nsstring alloc] initWithData:dataWebService encoding:NSUTF8StringEncoding];
    NSLog(@\"Response: %@\",responseString);

    [responseString release];
    [dataWebService release];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    NSLog(@\"Error during connection: %@\",[error description]);
}
    

解决方法

        使用JSON解析框架:http://code.google.com/p/json-framework/