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 given Node and optional user info mapping.

    Throws

    DecodingError or YamlError 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 given String and optional user info mapping.

    Throws

    DecodingError or YamlError 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 given Data and optional user info mapping.

    Throws

    DecodingError or YamlError 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

TopLevelDecoder