AFNetworking serializes forward slash making the JSON payload invalid
This is know problem. It actually behaves as designed (see https://stackoverflow.com/a/20448342/669586).
There are 3 possible solution:
Make your server aware of the possibility that strings can be escaped. In general, this is the best solution.
Use a different JSON encoder (e.g. SBJson) and encode the object to
NSData
instead of using AFNetworking default serializer.Encode using
NSJSONSerialization
and then convert the resulting data to aNSString
(usingNSUTF8StringEncoding
), sanitize it and convert it back toNSData
. Again, you have to do that before giving the object to AFNetworking.
The best way to implement 2 or 3 is setting a custom requestSerializer
on the AFHTTPSessionManager
instance. For example, see this answer for an example of implementing 3 (note it's in Swift).