如何删除\
和\n
。这两个人物即将到来。
{
PageNumber = 1;
businessCode = "{\n \"businessCode\" : \"[]\"\n}";
businessName = "";
categoryKeyword = "Ladies Traditional Wear Pagenumber";
languageCode = en;
location = "";
paginationSize = 5;
}
答案 0 :(得分:0)
可能低于答案对你有帮助。关注此
//just give your URL instead of my URL
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"Your URL"]];
[request setHTTPMethod:@"GET"];
[request setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"content-type"];
NSError *err;
NSURLResponse *response;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
//You need to check response.Once you get the response copy that and paste in ONLINE JSON VIEWER.If you do this clearly you can get the correct results.
//After that it depends upon the json format whether it is DICTIONARY or ARRAY
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:responseData options: NSJSONReadingMutableContainers error: &err];
从上面的代码中,您可以获得正确的JSON格式。试试这个。
答案 1 :(得分:-1)
NSMutableCharacterSet *charactersToRemove = [NSMutableCharacterSet new];
[charactersToRemove addCharactersInString:@"\n"];
[charactersToRemove addCharactersInString:@"\\"]; //This respresent obly one backslash, In Objective-c you have to support it with another slash
[jsonString stringByTrimmingCharactersInSet:charactersToRemove];