DictionaryEncoder
open class DictionaryEncoder
DictionaryEncoder facilitates the encoding of Encodable values into a dictionary.
-
The strategy to use for encoding
See moreDatevalues.Declaration
Swift
public enum DateEncodingStrategy -
The strategy to use for encoding
See moreDatavalues.Declaration
Swift
public enum DataEncodingStrategy -
The strategy to use for non-JSON-conforming floating-point values (IEEE 754 infinity and NaN).
See moreDeclaration
Swift
public enum NonConformingFloatEncodingStrategy -
The strategy to use for automatically changing the value of keys before encoding.
See moreDeclaration
Swift
public enum KeyEncodingStrategy -
The strategy to use in encoding dates. Defaults to
.deferredToDate.Declaration
Swift
open var dateEncodingStrategy: DateEncodingStrategy -
The strategy to use in encoding binary data. Defaults to
.base64.Declaration
Swift
open var dataEncodingStrategy: DataEncodingStrategy -
The strategy to use in encoding non-conforming numbers. Defaults to
.throw.Declaration
Swift
open var nonConformingFloatEncodingStrategy: NonConformingFloatEncodingStrategy -
The strategy to use for encoding keys. Defaults to
.useDefaultKeys.Declaration
Swift
open var keyEncodingStrategy: KeyEncodingStrategy -
Contextual user-provided information for use during encoding.
Declaration
Swift
open var userInfo: [CodingUserInfoKey : Any]
-
Initializes
selfwith default strategies.Declaration
Swift
public init()
-
Encodes the given top-level value and returns its Dictionary representation.
Throws
EncodingError.invalidValueif a non-conforming floating-point value is encountered during encoding, and the encoding strategy is.throw.Throws
An error if any value throws an error during encoding.Declaration
Swift
open func encode<T>(_ value: T) throws -> [String : Any] where T : EncodableParameters
valueThe value to encode.
Return Value
A new
Dictionaryvalue containing the encoded dictionary data.
View on GitHub
DictionaryEncoder Class Reference