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
YAMLDecoderinstance.Declaration
Swift
public convenience init(encoding: Parser.Encoding)Parameters
encodingString encoding,
-
Creates a
YAMLDecoderinstance.Declaration
Swift
public init() -
Decode a
Decodabletype from a givenNodeand optional user info mapping.Throws
DecodingErrororYamlErrorif 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.DecodableParameters
typeDecodabletype to decode.nodeYAML Node to decode.
userInfoAdditional key/values which can be used when looking up keys to decode.
Return Value
Returns the decoded type
T. -
Decode a
Decodabletype from a givenStringand optional user info mapping.Throws
DecodingErrororYamlErrorif 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.DecodableParameters
typeDecodabletype to decode.yamlYAML string to decode.
userInfoAdditional key/values which can be used when looking up keys to decode.
Return Value
Returns the decoded type
T. -
Decode a
Decodabletype from a givenDataand optional user info mapping.Throws
DecodingErrororYamlErrorif 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.DecodableParameters
typeDecodabletype to decode.yamlYAML data to decode.
userInfoAdditional 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: DecodableWithConfigurationParameters
typeThe type of the value to decode from the supplied YAML object.
dataThe YAML object
Datato decode.configurationA 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.DecodingConfigurationParameters
typeThe type of the value to decode from the supplied YAML object.
dataThe YAML object
Datato decode.configurationA 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: DecodableWithConfigurationParameters
typeThe type of the value to decode from the supplied YAML object.
dataThe YAML object
Datato decode.configurationA configuration instance provider to help decode types that don’t support encoding by themselves.
userInfoA 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.DecodingConfigurationParameters
typeThe type of the value to decode from the supplied YAML object.
dataThe YAML object
Datato decode.configurationA configuration instance provider to help decode types that don’t support encoding by themselves.
userInfoA 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
Decodabletype from a givenNodeand optional user info mapping.Throws
DecodingErrororYamlErrorif 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: DecodableWithConfigurationParameters
typeThe type of the value to decode from the supplied YAML node.
nodeYAML Node to decode.
configurationA configuration instance that provides additional information necessary for decoding.
userInfoA dictionary you use to customize the decoding process by providing contextual information.
Return Value
Returns the decoded type
T.
View on GitHub
Install in Dash