AFNetworking GET无效 - (字符94周围的转义序列无效。)

时间:2014-05-05 07:41:26

标签: ios objective-c afnetworking afnetworking-2

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];

[manager GET:@"http://xml.memurlar.net/mobile/json/news/headlines.aspx" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

我正在使用最新的 AFNetworking 。我想从上面使用的链接中获取对象。但我得到以下错误:

Error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid escape sequence around character 94.) UserInfo=0x1203e950 {NSDebugDescription=Invalid escape sequence around character 94.}

任何解决方案?

2 个答案:

答案 0 :(得分:1)

是的,API没有返回有效的JSON结构。问题就在这里:

  

“KPSS \'de kim hangi oturuma girecek?”

那个\不是一个有效的转义字符,需要去。你用什么来序列化那个JSON?

答案 1 :(得分:0)

//do not use the default json serializer.
manager.responseSerializer=[AFHTTPResponseSerializer serializer];