2

I'm using JSONKit with AFNetworking's AFHTTPClient (with AFJSONRequestOperation) and I can't seem to figure out how one might trigger the use of the mutableObjectFrom... methods of JSONKit rather than the normal parser methods which return (or arrays of) JKDictionary.

Is this possible without modifying AFNetworking?

Aaron
  • 371
  • 5
  • 13

3 Answers3

15

In the latest version of AFNetworking, you can achieve this without modifying code. After you create a AFJSONRequestOperation *operation & before you call [operation start], add

[operation setJSONReadingOptions:NSJSONReadingMutableContainers];

You can then iterate through the JSON and modify the underlying NSMutableDictionaries

mmackh
  • 3,550
  • 3
  • 35
  • 51
2

You can't do that without editing AFNetworking code.

In AFJSONUtilities.m change (line 103)

SEL _JSONKitSelector = NSSelectorFromString(@"objectFromJSONDataWithParseOptions:error:"); 

By

SEL _JSONKitSelector = NSSelectorFromString(@"mutableObjectFromJSONDataWithParseOptions:error:"); 
Mathieu Hausherr
  • 3,485
  • 23
  • 30
-1

For NSJSONSerialization based operation of AFNetworking, in AFJSONUtilities.m line 203, change:

NSUInteger readOptions = 0

to

NSUInteger readOptions =  NSJSONReadingMutableContainers 
Καrτhικ
  • 3,833
  • 2
  • 29
  • 42