Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 220.127.116.11 release ready!
Owner and Founder. Opencart
Codable is a type alias for the Encodable and Decodable protocols. According to Apple documentation “A type that can convert itself into and out of an external representation”.
Encodable Protocols:- The process in which custom type is converted into other representation is known as encoding or serialization. And to do so encodable protocols have to conform.
Decodable Protocols:- The process in which others’ representation is converted into your custom type is known as decoding or deserialization. And to do so decodable protocols have to conform.
And to support both encoding and decoding Codable protocols have to conform.
Let see an example.
Now Employee type can be encoded and decoded both.
It is used to encode our type to another type. Like converting into data.
Now, we will encode Employee into data.
when we print the data it prints in Byte.
Now, we will convert the data again into Employee type.
Below is the output of decoding.
If you only want to Encode then you have to conform to Encodable protocol and vice versa.
If you want to use a different key name in your custom type than the actual JSON key. In that case, we will use CodingKeys enum. And will conforms CodingKey protocol.
Let see an example of it.
You can also check other blogs from here. if you have any issue or suggestion you can leave your query/suggestion in the comment section.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.