YAMLDecoder
public class YAMLDecoder
extension YAMLDecoder: TopLevelDecoder
Codable
-style Decoder
that can be used to decode a Decodable
type from a given String
and optional
user info mapping. Similar to Foundation.JSONDecoder
.
-
Options to use when decoding from YAML.
See moreDeclaration
Swift
public struct Options
-
Options to use when decoding from YAML.
Declaration
Swift
public var options: YAMLDecoder.Options
-
Creates a
YAMLDecoder
instance.Declaration
Swift
public convenience init(encoding: Parser.Encoding)
Parameters
encoding
String encoding,
-
Creates a
YAMLDecoder
instance.Declaration
Swift
public init()
-
Decode a
Decodable
type from a givenNode
and optional user info mapping.Throws
DecodingError
orYamlError
if something went wrong while decoding.Declaration
Swift
public func decode<T>(_ type: T.Type = T.self, from node: Node, userInfo: [CodingUserInfoKey: Any] = [:]) throws -> T where T: Swift.Decodable
Parameters
type
Decodable
type to decode.node
YAML Node to decode.
userInfo
Additional key/values which can be used when looking up keys to decode.
Return Value
Returns the decoded type
T
. -
Decode a
Decodable
type from a givenString
and optional user info mapping.Throws
DecodingError
orYamlError
if something went wrong while decoding.Declaration
Swift
public func decode<T>(_ type: T.Type = T.self, from yaml: String, userInfo: [CodingUserInfoKey: Any] = [:]) throws -> T where T: Swift.Decodable
Parameters
type
Decodable
type to decode.yaml
YAML string to decode.
userInfo
Additional key/values which can be used when looking up keys to decode.
Return Value
Returns the decoded type
T
. -
Decode a
Decodable
type from a givenData
and optional user info mapping.Throws
DecodingError
orYamlError
if something went wrong while decoding.Declaration
Swift
public func decode<T>(_ type: T.Type = T.self, from yamlData: Data, userInfo: [CodingUserInfoKey: Any] = [:]) throws -> T where T: Swift.Decodable
Parameters
type
Decodable
type to decode.yaml
YAML data to decode.
userInfo
Additional key/values which can be used when looking up keys to decode.
Return Value
Returns the decoded type
T
. -
Encoding
Declaration
Swift
@available(*, deprecated, renamed: "options.encoding") public var encoding: Parser.Encoding { get }
-
Declaration
Swift
public typealias Input = Data
-
Declaration
Swift
public func decode<T>(_ type: T.Type, from: Data) throws -> T where T : Decodable
-
Returns a value of the type you specify, decoded from a YAML object.
Declaration
Swift
public func decode<T>(_ type: T.Type = T.self, from data: Data, configuration: T.DecodingConfiguration) throws -> T where T: DecodableWithConfiguration
Parameters
type
The type of the value to decode from the supplied YAML object.
data
The YAML object
Data
to decode.configuration
A decoding configuration that provides additional information necessary for decoding.
Return Value
A value of the specified type, if the decoder can parse the data.
-
Returns a value of the type you specify, decoded from a YAML object.
Declaration
Swift
public func decode<T: DecodableWithConfiguration, C: DecodingConfigurationProviding>( _ type: T.Type = T.self, from data: Data, configuration: C.Type ) throws -> T where T.DecodingConfiguration == C.DecodingConfiguration
Parameters
type
The type of the value to decode from the supplied YAML object.
data
The YAML object
Data
to decode.configuration
A configuration instance provider to help decode types that don’t support encoding by themselves.
Return Value
A value of the specified type, if the decoder can parse the data.
-
Returns a value of the type you specify, decoded from a YAML object.
Declaration
Swift
public func decode<T>(_ type: T.Type = T.self, from data: Data, configuration: T.DecodingConfiguration, userInfo: [CodingUserInfoKey: Any]) throws -> T where T: DecodableWithConfiguration
Parameters
type
The type of the value to decode from the supplied YAML object.
data
The YAML object
Data
to decode.configuration
A configuration instance provider to help decode types that don’t support encoding by themselves.
userInfo
A dictionary you use to customize the decoding process by providing contextual information.
Return Value
A value of the specified type, if the decoder can parse the data.
-
Returns a value of the type you specify, decoded from a YAML object.
Declaration
Swift
public func decode<T: DecodableWithConfiguration, C: DecodingConfigurationProviding>( _ type: T.Type = T.self, from data: Data, configuration: C.Type, userInfo: [CodingUserInfoKey: Any] ) throws -> T where T.DecodingConfiguration == C.DecodingConfiguration
Parameters
type
The type of the value to decode from the supplied YAML object.
data
The YAML object
Data
to decode.configuration
A configuration instance provider to help decode types that don’t support encoding by themselves.
userInfo
A dictionary you use to customize the decoding process by providing contextual information.
Return Value
A value of the specified type, if the decoder can parse the data.
-
Decode a
Decodable
type from a givenNode
and optional user info mapping.Throws
DecodingError
orYamlError
if something went wrong while decoding.Declaration
Swift
public func decode<T>(_ type: T.Type = T.self, from node: Node, configuration: T.DecodingConfiguration, userInfo: [CodingUserInfoKey: Any] = [:]) throws -> T where T: DecodableWithConfiguration
Parameters
type
The type of the value to decode from the supplied YAML node.
node
YAML Node to decode.
configuration
A configuration instance that provides additional information necessary for decoding.
userInfo
A dictionary you use to customize the decoding process by providing contextual information.
Return Value
Returns the decoded type
T
.