Serialize and deserialize instances of your types with implicit or customized encoding.
Encoding, Decoding, and Serialization
Topics
Custom Encoding and Decoding
Make your data types encodable and decodable for compatibility with external representations such as JSON.
typealias CodableA type that can convert itself into and out of an external representation.
protocol EncodableA type that can encode itself to an external representation.
protocol DecodableA type that can decode itself from an external representation.
protocol Coding KeyA type that can be used as a key for encoding and decoding.
struct Coding User Info KeyA user-defined key for providing context during encoding and decoding.
Encoders and Decoders
protocol EncoderA type that can encode values into a native format for external representation.
protocol DecoderA type that can decode values from a native format into in-memory representations.
enum Encoding ErrorAn error that occurs during the encoding of a value.
enum Decoding ErrorAn error that occurs during the decoding of a value.
Encoding Containers
protocol Single Value Encoding ContainerA container that can support the storage and direct encoding of a single non-keyed value.
struct Keyed Encoding ContainerA concrete container that provides a view into an encoder’s storage, making the encoded properties of an encodable type accessible by keys.
protocol Keyed Encoding Container ProtocolA type that provides a view into an encoder’s storage and is used to hold the encoded properties of an encodable type in a keyed manner.
protocol Unkeyed Encoding ContainerA type that provides a view into an encoder’s storage and is used to hold the encoded properties of an encodable type sequentially, without keys.
Decoding Containers
struct Keyed Decoding ContainerA concrete container that provides a view into a decoder’s storage, making the encoded properties of a decodable type accessible by keys.
protocol Single Value Decoding ContainerA container that can support the storage and direct decoding of a single nonkeyed value.
protocol Keyed Decoding Container ProtocolA type that provides a view into a decoder’s storage and is used to hold the encoded properties of a decodable type in a keyed manner.
protocol Unkeyed Decoding ContainerA type that provides a view into a decoder’s storage and is used to hold the encoded properties of a decodable type sequentially, without keys.
See Also
Tools for Your Types
Use your custom types in operations that depend on testing for equality or order and as members of sets and dictionaries.
Allow values of your type to be expressed using different kinds of literals.