Codable is a protocol that can convert a Swift object itself into and out of Data type. Codable is a type alias for Encodable and Decodable protocols. It is an easy to use official protocol for parsing JSON object from server to Swift object.

Encodable is used when Swift object has to be serialised and sent to server. On the other hand, Decodable is used when server JSON data is required to be deserialised.

Moreover, custom object conforming to Codable can now be saved to and retrieved from UserDefaults directly with only 3 steps. It saves a lot of boilerplate codes.

Swift UserDefault — Save Custom Object in 3 Steps ONLY!

Is saving custom object to UserDefaults difficult and tedious? You can now save and retrieve it with only 3 main steps…

medium.com

Let’s get started!

#codable #swift-programming #json #swift #ios

Swift Codable — JSON Parser
1.80 GEEK