- Codable 是Encodable 和Decodable 两个协议的组合
- Encodable:用在那些需要被编码的类型上
- Decodable:表示那些能够被解码的类型
public protocol Encodable {
func encode(to encoder: Encoder) throws
}
public protocol Decodable {
init(from decoder: Decoder) throws
}
- 参考文档:https://www.jianshu.com/p/9e0872471492