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