1:先在项目里引入json:

#import "JSON.h"

2:然后将服务端返回的数据进行反解码:

id jsonValue = [response JSONValue];

3:最后得到的就是一个数组

4:具体代码:

 

  1. - (IBAction)sendrequest:(id)sender { 
  2.     // ASIHTTPRequest function start    
  3.     NSURL *newurl = [NSURL URLWithString:address.text]; 
  4.     ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:newurl]; 
  5.     [request startSynchronous];     
  6.     NSError *error = [request error]; 
  7.     int i; 
  8.     if(!error) 
  9.     { 
  10.         NSString *response = [request responseString];  
  11.         id jsonValue = [response JSONValue]; 
  12.         for(i=0;i<[jsonValue count];i++) 
  13.         { 
  14.             NSLog(@"content is:%@",[jsonValue objectAtIndex:i]); 
  15.         } 
  16.         [response release]; 
  17.     } 
  18.      
  19.     // ASIHTTPRequest the end.