[ReactNative] Add more logging to RCTJSONParse

This commit is contained in:
Sumeet Vaidya 2015-03-24 17:47:59 -07:00
Родитель 94db4facf5
Коммит 3c0239a235
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -31,8 +31,14 @@ id RCTJSONParse(NSString *jsonString, NSError **error)
}
NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];
if (!jsonData) {
RCTLog(@"RCTJSONParse received the following string, which could not be losslessly converted to UTF8 data: '%@'", jsonString);
jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
if (jsonData) {
RCTLogWarn(@"RCTJSONParse received the following string, which could not be losslessly converted to UTF8 data: '%@'", jsonString);
} else {
// If our backup conversion fails, log the issue so we can see what strings are causing this (t6452813)
RCTLogError(@"RCTJSONParse received the following string, which could not be converted to UTF8 data: '%@'", jsonString);
return nil;
}
}
return [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingAllowFragments error:error];
}