Home YamlSerializer Class
YamlSerializer Class
Cancel

YamlSerializer Class

Namespace: Yaml2JsonNode

Inheritance: YamlSerializer 🡒 object

Provides common serializer functionality.

Methods

Deserialize(string yamlText, JsonSerializerOptions options)

Deserializes the first YAML document found in text to an object.

Declaration

1
public static T Deserialize(string yamlText, JsonSerializerOptions options)
ParameterTypeDescription
yamlTextstringThe YAML text.
optionsJsonSerializerOptions 

Returns

The object or null.

Parse(string yamlText)

Parses YAML text into a stream (collection of documents).

Declaration

1
public static YamlStream Parse(string yamlText)
ParameterTypeDescription
yamlTextstringThe YAML text.

Returns

A YAML stream representing the content of the text.

Serialize(YamlStream yaml, Action<SerializerBuilder> configure)

Serializes a YAML stream (a collection of documents) to a string.

Declaration

1
public static string Serialize(YamlStream yaml, Action<SerializerBuilder> configure)
ParameterTypeDescription
yamlYamlStreamThe stream.
configureAction<SerializerBuilder>(optional) YAML serializer configuration method.

Returns

The YAML string.

Serialize(YamlDocument yaml, Action<SerializerBuilder> configure)

Serializes a YAML document to a string.

Declaration

1
public static string Serialize(YamlDocument yaml, Action<SerializerBuilder> configure)
ParameterTypeDescription
yamlYamlDocumentThe document.
configureAction<SerializerBuilder>(optional) YAML serializer configuration method.

Returns

The YAML string.

Serialize(YamlNode yaml, Action<SerializerBuilder> configure)

Serializes a YAML node to a string

Declaration

1
public static string Serialize(YamlNode yaml, Action<SerializerBuilder> configure)
ParameterTypeDescription
yamlYamlNodeThe node.
configureAction<SerializerBuilder>(optional) YAML serializer configuration method.

Returns

The YAML string.

Serialize(T obj, JsonSerializerOptions options, Action<SerializerBuilder> configure)

Serializes an object to a YAML string

Declaration

1
public static string Serialize(T obj, JsonSerializerOptions options, Action<SerializerBuilder> configure)
ParameterTypeDescription
objTThe object.
optionsJsonSerializerOptions(optional) JSON serializer options.
configureAction<SerializerBuilder>(optional) YAML serializer configuration method.

Returns

The YAML string.

Contents