Skip to content

YamlDocument.Parse Method

Definition

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

Overloads

Method Description
Parse(ReadOnlyMemory<byte>, YamlReaderOptions) Parses UTF-8 YAML bytes and returns a ParsedJsonDocument containing the equivalent JSON representation.
Parse(string, YamlReaderOptions) Parses a YAML string and returns a ParsedJsonDocument 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 ParsedJsonDocument containing the equivalent JSON representation.
Parse(Stream, YamlReaderOptions) Parses UTF-8 YAML from a Stream and returns a ParsedJsonDocument containing the...

Parse(ReadOnlyMemory<byte>, YamlReaderOptions)

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

public static ParsedJsonDocument<TElement> Parse<TElement>(ReadOnlyMemory<byte> utf8Yaml, YamlReaderOptions options)
    where TElement : struct, IJsonElement<TElement>

Type Parameters

Parameter Description
TElement The type of the JSON element.

Parameters

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

Returns

ParsedJsonDocument<TElement>

A ParsedJsonDocument 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 ParsedJsonDocument containing the equivalent JSON representation.

public static ParsedJsonDocument<TElement> Parse<TElement>(string yaml, YamlReaderOptions options)
    where TElement : struct, IJsonElement<TElement>

Type Parameters

Parameter Description
TElement The type of the JSON element.

Parameters

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

Returns

ParsedJsonDocument<TElement>

A ParsedJsonDocument 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 ParsedJsonDocument containing the equivalent JSON representation.

public static ParsedJsonDocument<TElement> Parse<TElement>(ReadOnlySequence<byte> utf8Yaml, YamlReaderOptions options)
    where TElement : struct, IJsonElement<TElement>

Type Parameters

Parameter Description
TElement The type of the JSON element.

Parameters

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

Returns

ParsedJsonDocument<TElement>

A ParsedJsonDocument 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 ParsedJsonDocument containing the equivalent JSON representation.

public static ParsedJsonDocument<TElement> Parse<TElement>(ReadOnlyMemory<char> yaml, YamlReaderOptions options)
    where TElement : struct, IJsonElement<TElement>

Type Parameters

Parameter Description
TElement The type of the JSON element.

Parameters

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

Returns

ParsedJsonDocument<TElement>

A ParsedJsonDocument 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 ParsedJsonDocument containing the equivalent JSON representation. The stream will be read to completion.

public static ParsedJsonDocument<TElement> Parse<TElement>(Stream utf8YamlStream, YamlReaderOptions options)
    where TElement : struct, IJsonElement<TElement>

Type Parameters

Parameter Description
TElement The type of the JSON element.

Parameters

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

Returns

ParsedJsonDocument<TElement>

A ParsedJsonDocument 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