1 /*2 3 4 //json analytic System self-bringing method--5 6 //1. Get Road Strength7 nsstring *fielpath = [[NSBundle mainbundle]pathforresource:@ "Student.json" oftype:nil];8 9 //2. Convert files (JSON) under this path to binary dataTen NSData *data = [NSData Datawithcontentsoffile:fielpath]; One A //3. View what type of data the file is - - //Parameter if *, requires the object itself * * to represent the object address, write data to the address the nserror *error = nil; - Nsarray *array = [nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingmutablecontainers Error: &error]; - - if (error) { + NSLog (@ "%@", error); - } + A //parent pointer can point to child class object at //NSObject *idd = [[Student alloc]init]; - - Self.dataarray = [Nsmutablearray array]; - - For (nsdictionary *dic in array) { - in Student *student = [[Student alloc]initwithdictionary:dic]; - to [Self.dataarray addobject:student]; + } - the * $ Panax Notoginseng */ - the /* + A //Using third-party jsonkit files the + nsstring *fielpath = [[NSBundle mainbundle]pathforresource:@ "Student.json" oftype:nil]; - $ //JSON conversion to NSData binary data $ NSData *data = [NSData Datawithcontentsoffile:fielpath]; - //using Jsonkit for parsing - Nsarray *array = [data objectfromjsondata]; the - Wuyi Self.dataarray = [Nsmutablearray array]; the - For (nsdictionary *dic in array) { Wu - Student *student = [[Student alloc]initwithdictionary:dic]; About $ [Self.dataarray addobject:student]; - } - - A */
Data parsing _json (beginner)