I am facing some problem in parsing JSON using AFNetworking 2.0. It always executes the failure block when a new line character comes with response data.
My Code -
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
[manager GET:@"http://mobile.MYSERVICENAME/outbox.aspx?u=SONALI2547&p=25472870&sender=sjssgn" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
{
NSLog(@"%@", responseObject);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
NSLog(@"%@", error);
}];
ERROR -
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Unescaped control character around character 512.) UserInfo=0xa279660 {NSDebugDescription=Unescaped control character around character 512.}
I am check I am check my url on jsonlint it give me above error.
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]
) and print that string to the console. Then inspect character at index 512. Note: unescaped control chars are not allowed in a decoded JSON representing a source string. – CouchDeveloper