Is there any way to send some special character like ' , " in JSON string, If I try to send this character in JSON, then I am not able to get success response .
Here is the code :
NSMutableDictionary *dicWebServiceData = [[NSMutableDictionary alloc] init];
[dicWebServiceData setValue:@"Today's menu" forKey:@"description"];
NSString *strBulkData = [NSString stringWithFormat:@"bulk_data=[%@]",[dicWebService JSONRepresentation]];
strBulkData = [strBulkData stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSData *postData = [strBulkData dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",webServiceURL,strWebServiceName]];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
[req setHTTPMethod:@"POST"];
[req setTimeoutInterval:6000];
[req setValue:[NSString stringWithFormat:@"%d", postData.length] forHTTPHeaderField:@"Content-Length"];
[req setValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req setHTTPBody:postData];
Is there any way to pass this character in JSON ? Thanks,
You can't wrap a string literal over multiple lines without escaping the carriage returns. You should use \\ to make it multi line string. Hope it helps.
eg
NSString *size = [Content stringByEvaluatingJavaScriptFromString:@"return Subject.min(\
document.body.scrollHeight, document.documentElement.scrollHeight,\
document.body.offsetHeight, document.documentElement.offsetHeight,\
document.body.clientHeight, document.documentElement.clientHeight\
);"];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.