Shimen the main contribution, respect the work of the author, please do not reprint.
If the article is helpful to you, you are welcome to donate to the author, support Shimen, and donate any amount. Heavy on the mind ^_^
I want to donate: Click Donate
Cocos2d-x source code Download: Dot I teleport
Games Official Download:HTTP://DWZ.CN/RWTJL
Game video preview:http://dwz.cn/RzHHd
Game Development Blog:Http://dwz.cn/RzJzI
Game Source code transfer : Http://dwz.cn/Nret1
basic use of JSON in A.ios1. Parsing JSON data(1) JSON deserializationObject
{}
Structure of the key-value pairs for format {key:value, Key:value,...}
Ability to deserialize into nsdictionary in OC
Array
[]
format ["Java", "JavaScript", "VB",...]
Ability to deserialize into Nsarray in OC
Tips
The JSON data format is similar to the high-speed packaging method in OC
JSON has the same data format to support nesting (2) JSON toolStart with iOS 5. Using Nsjsonserialization to parse JSON
Other three common JSON parsing third-party libraries:
Sbjson because the API is easy to use, there may be some applications that remain
The developer of Jsonkit Jsonkit said: Jsonkit performance is better than Apple
Touchjson (3) Serialization & deserializationDeserialization
[Nsjsonserialization jsonobjectwithdata:data options:0 error:null];
Serialization of
[nsjsonserialization Datawithjsonobject:array options:0 error:null]; Sample:
1 //Send messages synchronously2NSData *data =[nsurlconnection sendsynchronousrequest:request returningresponse:nil Error:nil];3 4 //parsing Data5 if(data) {//Get Return Data6 //Unblock screen lock7 [Mbprogresshud Hidehud];8 9 //parsing JSON dataTenNsdictionary *dict =[nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingmutableleaves Error:nil]; One A //processing the returned data -NSString *result = dict[@"Success"]; - if(Result) { the [Mbprogresshud Showsuccess:result]; -}Else { -result = dict[@"Error"]; - if(Result) { + [Mbprogresshud Showerror:result]; - } + } A}Else { at[Mbprogresshud ShowError:@"the Internet is busy, please try again later"]; -}
Shimen the main contribution, respect the work of the author, please do not reprint.
Suppose the article is helpful to you. Welcome to donate to the author, support Shimen, donate amount arbitrarily. Heavy on the mind ^_^
I want to donate: Click Donate
Cocos2d-x source code Download: Dot I teleport
Games Official Download:HTTP://DWZ.CN/RWTJL
Game video preview:http://dwz.cn/RzHHd
Game Development Blog:Http://dwz.cn/RzJzI
Game Source code transfer : Http://dwz.cn/Nret1
Analysis of iOS multi-threading and network development JSON data