{} –>字典
[] –>数组
“”–>字符串
11/11.1–>NSNumber
true/false –>NSNumber
null–>NSNull(注意:这也是一个对象)
1.创建URL
2.根据URL创建请求
3.利用NSURLConnection发送请求
4.解析
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
   //json转dict
    //创建连接,要请求的jSON数据
    NSURL *url = [NSURL URLWithString:@"http://122.22.222.122:32812/login?username=sky5156&pwd=sky5156&type=JSON"];
    //创建请求
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    //发送请求
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        /**
         *  重要:其实就是拿到data使用下面方法就能转成字典
         *第一个参数:data    就是要转换的内容
         *第二个参数:options是枚举值   NSJSONReadingMutableContainers(规则的可变数组或者字典),
                                    NSJSONReadingMutableLeaves (解析出可变字符串.这个有问题,不用)
                                    NSJSONReadingAllowFragments (非规则的字典或数组用这个)
         *
         */
      NSMutableDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"%@",dict);
    }];
}
@end
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文:http://blog.csdn.net/applelg/article/details/47404195