Data parsing _json (beginner)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.