0
votes

I am getting this error

Error Domain=NSCocoaErrorDomain Code=3840 "Invalid escape sequence around character 746." UserInfo={NSDebugDescription=Invalid escape sequence around character 746.}

Here is my code to parse JSON:

NSString *strResponse = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
strResponse=[self stringByRemovingControlCharacters:strResponse];
NSData *jsonData =  [strResponse dataUsingEncoding:NSUTF8StringEncoding];
responseObject = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&serializationError

Using this code I am getting response object in other API. but in my API contains HTML tags.

My issue is I am getting JSON string but it is not parsing in JSON. for this API I am getting error

"Error Domain=NSCocoaErrorDomain Code=3840".

My conclusion is that JSON is not parsing properly in above code.

1
I think your API doesn't return valid JSON or maybe some error in backend .. better to contact your backend developerEI Captain v2.0
This is not at all a good practise to ask same question as 2 different question. You must edit your main question to add details. If you think you are not getting much attention try to give bounty to that question.iYoung
@iYoung i deleted last questionKrutarth Patel
Awesome. Thanks for getting my point.iYoung
can you please log strResponse value and add to question, By which we can see what things you should remove. Other wise no one's will able to help you...Wolverine

1 Answers

0
votes

The string from Ur backend may be invalid JSON,it may contain "\s""\n""\t" or other tab character。And in Xcode u print it will not see the tab character,the console will not print them.You may get the JSON and find if there are tab characters.