YamlNode Class

A node of the document object model: a YamlMapping, a YamlSequence or a YamlValue, like JsonNode in System.Text.Json.

public abstract class YamlNode

Remarks

A YamlStreamDocument holds the root node of a document, and a YamlStream holds documents: they are not nodes. For a read-only document that does not create an object per node, see YamlDocument.

Constructors

NameDescription
YamlNode()

YamlNode()

protected YamlNode()

No documentation is available.

Properties

NameDescription
AnchorGets or sets anchor.
IsCanonicalGets is Canonical.
TagGets or sets tag.

Anchor

Gets or sets anchor.

public abstract string? Anchor { get; set; }

Property value

string?

IsCanonical

Gets is Canonical.

public abstract bool IsCanonical { get; }

Property value

bool

Tag

Gets or sets tag.

public abstract string? Tag { get; set; }

Property value

string?

Methods

NameDescription
DeepClone()Creates a deep clone of the current node.
EnumerateEvents()Enumerates parsing events for this YAML node.
FromObject(object, YamlSerializerOptions?, Type?)Creates a YAML node from an object.
ToObject(Type, YamlSerializerOptions?)Converts this YAML node to an object.
ToObject<T>(YamlSerializerOptions?)Converts this node to an instance of T.
ToString()Returns a string representation of the current instance.
WriteTo(IEmitter, bool)Writes the node as a YAML document.
WriteTo(TextWriter, bool)Writes the node as a YAML document.

DeepClone()

Creates a deep clone of the current node.

public abstract YamlNode DeepClone()

Returns

YamlNode

EnumerateEvents()

YamlNode.cs

Enumerates parsing events for this YAML node.

public IEnumerable<ParsingEvent> EnumerateEvents()

FromObject(object, YamlSerializerOptions?, Type?)

YamlNode.cs

Creates a YAML node from an object.

public static YamlNode FromObject(object value, YamlSerializerOptions? options = null, Type? expectedType = null)

Parameters

value object
options YamlSerializerOptions?
expectedType Type?

Returns

YamlNode

ToObject overloads

ToObject(Type, YamlSerializerOptions?)

YamlNode.cs

Converts this YAML node to an object.

public object? ToObject(Type type, YamlSerializerOptions? options = null)
Parameters
type Type
options YamlSerializerOptions?
Returns

object?

ToObject<T>(YamlSerializerOptions?)

YamlNode.cs

Converts this node to an instance of T.

public T? ToObject<T>(YamlSerializerOptions? options = null)
Type parameters
T
Parameters
options YamlSerializerOptions?
Returns

T?

ToString()

YamlNode.cs

Returns a string representation of the current instance.

public override string ToString()

Returns

string

WriteTo overloads

WriteTo(IEmitter, bool)

YamlNode.cs

Writes the node as a YAML document.

public void WriteTo(IEmitter emitter, bool suppressDocumentTags = false)
Parameters
emitter IEmitter
suppressDocumentTags bool

WriteTo(TextWriter, bool)

YamlNode.cs

Writes the node as a YAML document.

public void WriteTo(TextWriter writer, bool suppressDocumentTags = false)
Parameters
writer TextWriter
suppressDocumentTags bool