I feel JSON parsing, and what's important is the processing of the results after JSON parsing
JSON is parsed as a dictionary, but it is possible to include dictionaries and arrays in the dictionary, which can also contain dictionaries.
Parsing of returned data requested by the client
The following is a brief introduction to the JSON parsing process
Actually, just a word.
"Data is the parsing"!!!!!!!!!!!!!!
Xcode comes with parsing class nsjsonserialization from data to the dictionary
Nsdictionary *weatherdic = [nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingmutableleaves Error: &error];
This is a common JSON parsing method, which is simpler and quicker than the following parsing methods.
Touchjson
Store the parsed content in a dictionary
Nsdictionary *prootdic = [[Cjsondeserializer deserializer]deserialize:data error:&error];
The parse object here is the NSData type
Sbjson
Gets a parser object
Sbjsonparser *parser = [[[Sbjsonparser alloc] init]autorelease];
Gets the dictionary returned after parsing the JSON string
Nsdictionary *rootdic = [parser objectwithstring:string error:&error];
It is important to note that the parsed data is decoded to the NSString type before it can be parsed
Jsonkit
Gets the parsed dictionary (parsing is complete and the return value is the dictionary type)
Nsdictionary *pweatherdic = [jsonstr objectfromjsonstringwithparseoptions:jkparseoptionlooseunicode];//Unified Coding Standard
Note JSONSTR or the data first decoded to the NSString type, then jsonstr directly with the analytic method on the line
It comes with a way to convert data into nsstring types.
NSString *string = [[NSString alloc]initwithdata:data encoding:nsutf8stringencoding];
Multiple ways to parse JSON in iOS