From 09cf2d39e22aa6f2f43f56924bebd365e48886d7 Mon Sep 17 00:00:00 2001 From: Mathijs Kadijk Date: Fri, 30 Nov 2012 14:12:59 -0800 Subject: [PATCH] [Issue #660] Add workaround for NSJSONSerialization crash with Unicode character escapes in JSON response Signed-off-by: Mattt Thompson --- AFNetworking/AFJSONRequestOperation.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 77ac8eb..78f3bb2 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -67,7 +67,10 @@ static dispatch_queue_t json_request_operation_processing_queue() { if ([self.responseData length] == 0) { self.responseJSON = nil; } 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;