1, do not waste time, this code through the practice of testing through!
// Network Request code snippet
//post Request
nsurl * url=[ nsurl urlwithstring : @ "Http://192.168.253.101:8080/ERP/mobile/login.action" ];
nsmutableurlrequest *request =[[nsmutableurlrequestalloc] Initwithurl: URLcachepolicy:nsurlrequestuseprotocolcachepolicytimeoutinterval: ];
// Set Request mode
[RequestSethttpmethod:@ "POST"];
// Set parameters
nsstring *str=@ "Username=a023&password=1&master=uas";
nsdata *data=[strdatausingencoding:nsutf8stringencoding];
[RequestSethttpbody:d ATA];
// connection Server
nsdata *received=[nsurlconnectionsendsynchronousrequest: Request Returningresponse:nilerror:nil];
nsstring *strl=[[nsstringalloc]initwithdata: Received encoding:nsutf8stringencoding];
//NSLog (@ " result:%@", Strl); ---Custom JSON format string containing collections and arrays in the form of native class library parsing
nserror *error;
nsstring *temstr=@ "{\" count\ ": 50,\" allprocess\ ": [{\" name\ ": \" Holy Angels \ "},{\" Name\ ": \" commodity angel \ "},{\" name\ ": \" beautiful angel \ "}]}";
NSLog (@ "temstr=%@", TEMSTR);
nsdata *rdata=[temstrdatausingencoding:nsutf8stringencoding];
NSLog (@ "rdata=%@", rdata);
nsdictionary *json=[temstrobjectfromjsonstringwithparseoptions: Jkparseoptionlooseunicode];
NSLog (@ "json=%@", JSON);
nsarray *elist=[json objectforkey:@ "allprocess"];
nsstring *uu=[elist objectatindex:1];
nsstring *u_name=[[elist objectatindex:1] objectforkey:@ "name"];
NSLog (@ "elist=%@", Elist);
NSLog(@ "elist=%@", UU);
NSLog (@ "elist=%@", U_name);
for (int i=0; i<[elistcount];i++) {
NSLog(@ " traversing array \ n%i=%@", I,[[elistobjectatindex: i] o Bjectforkey:@ "name"]);
}
iOS Development topic--conversion parsing JSON format for character formatting (native class library parsing)