JSON (JavaScript Object Notation) is a lightweight data interchange format. JSON-specific tutorials can be found in JSON China:http://www.json.org.cn/index.htm , and, of course, the JSON Online validation format tool:http://www.bejson.com/ , you can refer to the other tutorials for further learning about JSON. The lightweight JSON is relative to the structure of the XML document, describing fewer project characters, so the number of characters required to describe the same data is less, of course, the speed of transmission will increase and the flow will be reduced.
Like Weibo, a lot of the data on the microblogging service is JSON, which needs to be parsed locally, because Web and mobile platform development requires as little traffic as possible, and the speed requirement is faster, so JSON becomes the ideal data exchange language.
The process of writing data as a JSON structure is called an "encoding" process, which is a write process. The process of reading data from a JSON document is called a "decoding" process, which is the parsing and reading process.
The following is a list of some common parsing frameworks for JSON:
(1) Sbjson
(2) Touchjson
(3) Yajl, based on the Sbjson, the inside is optimized, the underlying API is written in C, the upper API is objective-c written, the user can have many different choices. It does not support ARC, Source: http://lloyd.github.com/yajl/
(4) Jsonkit
(5) Nextivejson, this framework does not support ARC, Source: Http://github.com/nextive/NextiveJson
(6) Nsjsonserialization, from the naming rules of this framework, I think you guessed it is Apple's own JSON parsing framework, it was iOS5 after the proposed.
Specific simple examples can also refer to this blog: http://blog.csdn.net/enuola/article/details/7903632/Some methods in the iOS7 later version of the warning, it will be modified to iOS7 later support methods.
The following is a simple implementation using Nsjsonserialization to parse, of course, can also use a third-party framework, download the source code, installation, if not supported ARC configuration can be. Parse directly in the Viewdidload method
-(void) viewdidload{[Super viewdidload];//do no 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 (Relo AdView:) name:@ "Reloadviewnotification" Object:nil]; Notesnextivejsonparser *parser = [Notesnextivejsonparser new]; Start parsing [parser start]; nsstring* path = [[NSBundle mainbundle] pathforresource:@ "Test" oftype:@ "json"]; Parse a file called Test.json nsdata *jsondata = [[NSData alloc] initwithcontentsoffile:path]; Nserror *error; ID jsonobj = [nsjsonserialization jsonobjectwithdata:jsondata Options:nsjsonreadingmutablecontainers error:&error]; if (!jsonobj | | error) {NSLOG (@ "JSON decoding failed"); } self.listdata = [jsonobj objectforkey:@ "Record"]; }
If there is no, also hope pointing!
JSON Data Interchange Format in IOS