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
.
-
Creates a
YAMLDecoder
instance.Declaration
Swift
public init(encoding: Parser.Encoding = .default)
Parameters
encoding
Encoding,
.default
if omitted. -
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
public var encoding: Parser.Encoding
-
Declaration
Swift
public typealias Input = Data
-
Declaration
Swift
public func decode<T>(_ type: T.Type, from: Data) throws -> T where T : Decodable