Skip to content

YamlDocument.Parse Method

Definition

Namespace: Corvus.Yaml
Assembly: Corvus.Text.Json.dll

Overloads

Method Description
Parse(ReadOnlyMemory<byte>, YamlReaderOptions) Parses UTF-8 YAML bytes and returns a JsonDocument containing the equivalent JSON representation.
Parse(string, YamlReaderOptions) Parses a YAML string and returns a JsonDocument containing the equivalent JSON representation.
Parse(ReadOnlySequence<byte>, YamlReaderOptions) Parses UTF-8 YAML bytes from a ReadOnlySequence and returns a...
Parse(ReadOnlyMemory<char>, YamlReaderOptions) Parses a YAML character memory and returns a JsonDocument containing the equivalent JSON representation.
Parse(Stream, YamlReaderOptions) Parses UTF-8 YAML from a Stream and returns a JsonDocument con...

Parse(ReadOnlyMemory<byte>, YamlReaderOptions)

Parses UTF-8 YAML bytes and returns a JsonDocument containing the equivalent JSON representation.

public static JsonDocument Parse(ReadOnlyMemory<byte> utf8Yaml, YamlReaderOptions options)

Parameters

Name Type Description
utf8Yaml ReadOnlyMemory<byte> The UTF-8 encoded YAML bytes.
options YamlReaderOptions Optional YAML reader options. (optional)

Returns

JsonDocument

A JsonDocument that must be disposed when no longer needed.

Exceptions

Exception Description
YamlException The YAML content is invalid.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Parse(string, YamlReaderOptions)

Parses a YAML string and returns a JsonDocument containing the equivalent JSON representation.

public static JsonDocument Parse(string yaml, YamlReaderOptions options)

Parameters

Name Type Description
yaml string The YAML content as a string.
options YamlReaderOptions Optional YAML reader options. (optional)

Returns

JsonDocument

A JsonDocument that must be disposed when no longer needed.

Exceptions

Exception Description
YamlException The YAML content is invalid.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Parse(ReadOnlySequence<byte>, YamlReaderOptions)

Parses UTF-8 YAML bytes from a ReadOnlySequence and returns a JsonDocument containing the equivalent JSON representation.

public static JsonDocument Parse(ReadOnlySequence<byte> utf8Yaml, YamlReaderOptions options)

Parameters

Name Type Description
utf8Yaml ReadOnlySequence<byte> The UTF-8 encoded YAML bytes as a sequence.
options YamlReaderOptions Optional YAML reader options. (optional)

Returns

JsonDocument

A JsonDocument that must be disposed when no longer needed.

Exceptions

Exception Description
YamlException The YAML content is invalid.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Parse(ReadOnlyMemory<char>, YamlReaderOptions)

Parses a YAML character memory and returns a JsonDocument containing the equivalent JSON representation.

public static JsonDocument Parse(ReadOnlyMemory<char> yaml, YamlReaderOptions options)

Parameters

Name Type Description
yaml ReadOnlyMemory<char> The YAML content as a character memory.
options YamlReaderOptions Optional YAML reader options. (optional)

Returns

JsonDocument

A JsonDocument that must be disposed when no longer needed.

Exceptions

Exception Description
YamlException The YAML content is invalid.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Parse(Stream, YamlReaderOptions)

Parses UTF-8 YAML from a Stream and returns a JsonDocument containing the equivalent JSON representation. The stream will be read to completion.

public static JsonDocument Parse(Stream utf8YamlStream, YamlReaderOptions options)

Parameters

Name Type Description
utf8YamlStream Stream The stream containing UTF-8 encoded YAML bytes.
options YamlReaderOptions Optional YAML reader options. (optional)

Returns

JsonDocument

A JsonDocument that must be disposed when no longer needed.

Exceptions

Exception Description
ArgumentNullException utf8YamlStream is null.
YamlException The YAML content is invalid.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests.

Open an issue