[Issue #660] Add workaround for NSJSONSerialization crash with Unicode character escapes in JSON response

Signed-off-by: Mattt Thompson <m@mattt.me>
This commit is contained in:
Mathijs Kadijk 2012-11-30 14:12:59 -08:00 committed by Mattt Thompson
parent 607e91b5b8
commit 09cf2d39e2

View file

@ -67,7 +67,10 @@ static dispatch_queue_t json_request_operation_processing_queue() {
if ([self.responseData length] == 0) { if ([self.responseData length] == 0) {
self.responseJSON = nil; self.responseJSON = nil;
} else { } else {
self.responseJSON = [NSJSONSerialization JSONObjectWithData:self.responseData options:self.JSONReadingOptions error:&error]; // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character
// See http://stackoverflow.com/a/12843465/157142
NSData *JSONData = [self.responseString dataUsingEncoding:self.responseStringEncoding];
self.responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:self.JSONReadingOptions error:&error];
} }
self.JSONError = error; self.JSONError = error;