zoukankan      html  css  js  c++  java
  • IOS 解析JSON

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        self.navigationItem.leftBarButtonItem = self.editButtonItem;
        
        self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
        
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(reloadView:)
                                                    name:@"reloadViewNotification"
                                                object:nil];
        
       NotesNextiveJsonParser *parser = [NotesNextiveJsonParser new];
      //开始解析
        [parser start];

        NSString* path = [[NSBundle mainBundle] pathForResource:@"Notes" ofType:@"json"];
        NSData *jsonData = [[NSData alloc] initWithContentsOfFile:path];
        
        NSError *error;
        
        id jsonObj = [NSJSONSerialization JSONObjectWithData:jsonData
                                                     options:NSJSONReadingMutableContainers error:&error];

        if (!jsonObj || error) {
            NSLog(@"JSON解码失败");
        }
        self.listData = [jsonObj objectForKey:@"Record"];
        
    }

     
  • 相关阅读:
    【对拍√】
    hdu5791 TWO
    luogu P1220 关路灯
    【NOI2001】食物链
    【HAOI2016】食物链
    luogu P1006 传纸条
    可持久化平衡树
    可持久化并查集
    线段树合并(【POI2011】ROT-Tree Rotations)
    可持久化数组
  • 原文地址:https://www.cnblogs.com/zhongxuan/p/4858119.html
Copyright © 2011-2022 走看看