IPhone- \ problem in JSON Parsing

I am using the JSON parsing object library and am running into some problems. My webservice is returning a JSON response. My Parser doesn't work because there is a "\" character in the response line. The answer line is like ":\/\/68.491.5.780\/iphoneapplication"

but I want to be like "://68.491.5.780/"

. could you please help me in this regard. and my code goes here ...

NSURL *url=[NSURL URLWithString:
  @"http:// url address/Accountservice/Security/ValidateAccess?accesscode=abcd&type=0"];

NSData *postData = 
  [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];

      

So, is anyone here to remove the entire back "\" in the response received from the web service.

+3


source to share


1 answer


you can replace \ with simple words: -

NSString *str =[NSString stringWithFormat:@"%@",@" hi \ hoowoer"];

str = [str stringByReplacingOccurrencesOfString:@"\""
                                     withString:@""];
NSLog(@"==%@",str);

      



OUTPUT

hi hoowoer

+4


source







All Articles