简单ios json解析处理

来源:互联网 发布:windows ad域的作用 编辑:程序博客网 时间:2024/06/07 01:43

 //载一个NSURL对象

    NSURLRequest *request = [NSURLRequestrequestWithURL:[NSURLURLWithString:@"http://openapi.baidu.com/public/2.0/bmt/translate"]];

    //请求的url数据放到NSData对象中

    NSData *response = [NSURLConnectionsendSynchronousRequest:request returningResponse:nilerror:nil];

    //IOS5带解析类NSJSONSerializationresponse中解析出数据放到字典中

    NSDictionary *weatherDic = [NSJSONSerializationJSONObjectWithData:response options:NSJSONReadingMutableLeaveserror:&error];

    

   NSLog(@"字典里面的内容-->%@", weatherDic );

原创粉丝点击