From 5d37e534f7fe6d20feefe0b7d63c6548006e73e2 Mon Sep 17 00:00:00 2001 From: Jeremy Foo Date: Wed, 17 Oct 2012 14:08:41 +0800 Subject: [PATCH] Updates AFJSONRequestOperation to allow JSON parsing options since it is now using the NSJSONSerialization class by default --- AFNetworking/AFJSONRequestOperation.h | 7 ++++++- AFNetworking/AFJSONRequestOperation.m | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/AFNetworking/AFJSONRequestOperation.h b/AFNetworking/AFJSONRequestOperation.h index f5ead5b..738f71b 100644 --- a/AFNetworking/AFJSONRequestOperation.h +++ b/AFNetworking/AFJSONRequestOperation.h @@ -33,7 +33,7 @@ - `application/json` - `text/json` - @warning JSON parsing will automatically use JSONKit, SBJSON, YAJL, or NextiveJSON, if provided. Otherwise, the built-in `NSJSONSerialization` class is used, if available (iOS 5.0 and Mac OS 10.7). If the build target does not either support `NSJSONSerialization` or include a third-party JSON library, a runtime exception will be thrown when attempting to parse a JSON request. + @warning JSON parsing will use the built-in `NSJSONSerialization` class. */ @interface AFJSONRequestOperation : AFHTTPRequestOperation @@ -46,6 +46,11 @@ */ @property (readonly, nonatomic, strong) id responseJSON; +/** + A bitmask of options that will be used by the NSJSONSerialization class that parses the JSON data from the response. + */ +@property (readwrite) NSJSONReadingOptions parseOptions; + ///---------------------------------- /// @name Creating Request Operations ///---------------------------------- diff --git a/AFNetworking/AFJSONRequestOperation.m b/AFNetworking/AFJSONRequestOperation.m index 7fa9669..c8def67 100644 --- a/AFNetworking/AFJSONRequestOperation.m +++ b/AFNetworking/AFJSONRequestOperation.m @@ -66,7 +66,7 @@ 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:0 error:&error]; + self.responseJSON = [NSJSONSerialization JSONObjectWithData:self.responseData options:self.parseOptions error:&error]; } self.JSONError = error;