Difference between Post & Get method in Json Parsing in ios -


i implement json parsing follow:

-(void)getallevent {             sbjson *json = [sbjson new];     json.humanreadable = yes;     responsedata = [[nsmutabledata data] retain];      nsstring *service = @"/getallvenue";      nsstring *str;     str = @"calagary";     nsstring *requeststring = [nsstring stringwithformat:@"{\"cityname\":\"%@\"}",str];      //nslog(@"request string:%@",requeststring);      //    nsstring *requeststring = [nsstring stringwithformat:@"{\"getalleventsdetails\":\"%@\"}",service];     nsdata *requestdata = [nsdata datawithbytes: [requeststring utf8string] length: [requeststring length]];      nsstring *fileloc = [[nsbundle mainbundle] pathforresource:@"urlname" oftype:@"plist"];     nsdictionary *filecontents = [[nsdictionary alloc] initwithcontentsoffile:fileloc];     nsstring *urlloc = [filecontents objectforkey:@"url"];     urlloc = [urlloc stringbyappendingstring:service];     //nslog(@"url : %@",urlloc);      nsmutableurlrequest *request = [[nsmutableurlrequest alloc] initwithurl: [nsurl urlwithstring: urlloc]];       nsstring *postlength = [nsstring stringwithformat:@"%d", [requestdata length]];     [request sethttpmethod: @"post"];     [request setvalue:postlength forhttpheaderfield:@"content-length"];     [request setvalue:@"application/json" forhttpheaderfield:@"content-type"];     [request sethttpbody: requestdata];      //    self.connection = [nsurlconnection connectionwithrequest:request delegate:self];        nserror *resperror = nil;     nsdata *returndata = [nsurlconnection sendsynchronousrequest: request returningresponse: nil error: &resperror ];      if (resperror)      {         nsstring *msg = [nsstring stringwithformat:@"connection failed! error - %@ %@",                          [resperror localizeddescription],                          [[resperror userinfo] objectforkey:nsurlerrorfailingurlstringerrorkey]];            uialertview *alertview = [[uialertview alloc] initwithtitle:@"check network connection"  message:msg delegate:self cancelbuttontitle:@"ok"                                                    otherbuttontitles:nil];         [alertview show];         [alertview release];      }      else     {         nsstring *responsestring = [[nsstring alloc] initwithdata:returndata encoding: nsutf8stringencoding];          nsdictionary *results = [[responsestring jsonvalue] retain];         //nslog(@" %@",results);         nsstring *extractusers = [[results objectforkey:@"d"] retain];         nsdictionary *finalresult = [[extractusers jsonvalue] retain];         nslog(@"final results : %@",finalresult);         listofevents = [finalresult objectforkey:@"list of event details of given venue"]; 

}

using code, slow down app. how can parse json in background? *is right post method? difference between post & method?*

is there other way json parsing?

you using synchronous request executed on main thread if need in background use asynchronous loading.

post method: post method generates form collection, sent http request body. values typed in form stored in form collection.

get method: method sends information appending url (with question mark) , stored querystring collection. querystring collection passed server name/value pair. length of url should less 255 characters.

an http request client server, asking resource.  http post upload of data (form information, image data, whatever) client server. 

check answer more details : what-is-the-difference-between-post-and-get


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -