IOS开发:解析服务器端的json数据

    //连接字符串
    NSString *urlstring = @"http://openapi.baidu.com/public/2.0/bmt/translate";
    //构造request对象
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlstring]];
    [request setHTTPMethod:@"GET"];
    NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:Nil error:nil];
    //解析json数据到字典中,其中NSJSONReadingMutableContainers表示解析出的字典可以被修改
    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:Nil];

 

你可能感兴趣的:(ios)