I am using SBJson framework (also known as json-framework) for the iOS.
When parsing a certain JSON file, I am getting the following error: -JSONValue failed. E
I have a great solution for it. Apply this method for remove escaped characters.
-(NSString *)removeUnescapedCharacter:(NSString *)inputStr
{
NSCharacterSet *controlChars = [NSCharacterSet controlCharacterSet];
NSRange range = [inputStr rangeOfCharacterFromSet:controlChars];
if (range.location != NSNotFound)
{
NSMutableString *mutable = [NSMutableString stringWithString:inputStr];
while (range.location != NSNotFound)
{
[mutable deleteCharactersInRange:range];
range = [mutable rangeOfCharacterFromSet:controlChars];
}
return mutable;
}
return inputStr;
}
Call this method with passing your output string like this
NSString *output = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"yourUrlString"] encoding:NSUTF8StringEncoding error:nil];
output = [self removeUnescapedCharacter:output];