iPhone中的JSON Web服务问题?

iPhone中的JSON Web服务问题?,iphone,ios,json,web-services,Iphone,Ios,Json,Web Services,目前我正在iPhone应用程序中工作,使用JSON发送请求并获取响应以读取请求 请求(示例url): 我引用了来自浏览器(Firefox)的响应: 我在xcode中尝试过: NSString *urlString = [NSString stringWithFormat:@" http://www.Genifer.com/index.php?"]; NSString *parameter = [NSString stringWithFormat:@"q=api/username-

目前我正在iPhone应用程序中工作,使用JSON发送请求并获取响应以读取请求

请求(示例url):

我引用了来自浏览器(Firefox)的响应:

我在xcode中尝试过:

NSString *urlString = [NSString stringWithFormat:@" http://www.Genifer.com/index.php?"];
        NSString *parameter = [NSString stringWithFormat:@"q=api/username-available&username=stephen"];   

        NSData *parameterData = [parameter dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
        NSURL *url = [NSURL URLWithString:urlString];

        NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];

        [theRequest addValue: @"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
        [theRequest setHTTPMethod:@"POST"];
        [theRequest setHTTPBody:parameterData]; 

        NSURLConnection *connection = [[NSURLConnection alloc] 
                                       initWithRequest:theRequest delegate:self];

        if( connection )
        {
            mutableData = [[NSMutableData alloc] init];
        }
        else 
        {

        } 


-(void) connection:(NSURLConnection *) connection didReceiveResponse:(NSURLResponse *)response
{
    [mutableData setLength:0]; 
    NSLog(@"mutableData:%@",mutableData);
}

-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [mutableData appendData:data];
    NSLog(@"mutableData:%@",mutableData);

}

-(void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    [mutableData release];
    [connection release];
    return;
}


-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{


        NSString *jsonStr = [[NSString alloc] initWithData:mutableData encoding:NSUTF8StringEncoding]; 
        NSLog(@"JSonSTr : %@", jsonStr);

}
答复如下:

 JSonSTr : <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
JSonSTr:
我在Firefox浏览器中引用请求以获得类似{“status”:true,“result”:true}的响应。 但我尝试在xcode中集成相同的请求,但响应不同,如何修复? 请帮帮我


提前谢谢你能帮我查一下吗

NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSDictionary *jsonDict = [jsonString JSONValue];
通过执行以下操作检查字典中弹出的值

 NSDictionary *question = [jsonDict objectForKey:@"status"];

我已经从jsonString NSLOG-JSonSTr得到了响应:让我们一步一步地做吧,我认为您发送的请求不是JSOn格式的,这就是为什么它不向您发送JSOn。下面是发送JSOn请求需要做的一件快速的事情,接受和内容类型应该是JSOn值
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSDictionary *jsonDict = [jsonString JSONValue];
 NSDictionary *question = [jsonDict objectForKey:@"status"];