YAMLEncoder

public class YAMLEncoder

Codable-style Encoder that can be used to encode an Encodable type to a YAML string using optional user info mapping. Similar to Foundation.JSONEncoder.

  • Options to use when encoding to YAML.

    Declaration

    Swift

    public typealias Options = Emitter.Options
  • Options to use when encoding to YAML.

    Declaration

    Swift

    public var options: YAMLEncoder.Options
  • Creates a YAMLEncoder instance.

    Declaration

    Swift

    public init()
  • Encode a value of type T to a YAML string.

    Throws

    EncodingError if something went wrong while encoding.

    Declaration

    Swift

    public func encode<T>(_ value: T, userInfo: [CodingUserInfoKey : Any] = [:]) throws -> String where T : Encodable

    Parameters

    value

    Value to encode.

    userInfo

    Additional key/values which can be used when looking up keys to encode.

    Return Value

    The YAML string.