简体   繁体   中英

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM