Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to get pure JSON response with AFNetworking Obj-C?

I already have an architecture setup with AFNetworking in my iOS app that is written in Obj-C. It returns the response as a Dictionary but I would like to play around with a pure JSON response to try Codable in Swift 4. Is that possible? Or what would be my options here?

like image 343
J. Doe Avatar asked Nov 17 '17 21:11

J. Doe


1 Answers

One possible solution recreate a JSON :

var dataJson = try! JSONSerialization.data(withJSONObject: responseObject, options: JSONSerialization.WritingOptions.prettyPrinted)
var objCodable = try! JSONDecoder().decode(ObjCodable.self, from: dataJson)
like image 109
Matthieu Lemonnier Avatar answered Nov 15 '22 00:11

Matthieu Lemonnier