Skip to content

YamlDocument.ConvertToYamlString Method

Definition

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

Overloads

Method Description
ConvertToYamlString(ref TElement, YamlWriterOptions) Converts a JSON element to a YAML string.
ConvertToYamlString(string, YamlWriterOptions) Converts a JSON string to a YAML string.
ConvertToYamlString(ReadOnlySpan<byte>, YamlWriterOptions) Converts UTF-8 JSON bytes to a YAML string.

ConvertToYamlString(ref TElement, YamlWriterOptions)

Converts a JSON element to a YAML string.

public static string ConvertToYamlString<TElement>(ref TElement element, YamlWriterOptions options)
    where TElement : struct, IJsonElement<TElement>

Type Parameters

Parameter Description
TElement The type of the JSON element.

Parameters

Name Type Description
element ref TElement The JSON element to convert.
options YamlWriterOptions Optional YAML writer options. (optional)

Returns

string

A string containing the YAML representation of the JSON element.

Remarks

The converter walks the element tree directly through the IJsonDocument APIs, using zero-allocation index-based enumeration for all IJsonElement implementations.

Applies To

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

ConvertToYamlString(string, YamlWriterOptions)

Converts a JSON string to a YAML string.

public static string ConvertToYamlString(string json, YamlWriterOptions options)

Parameters

Name Type Description
json string The JSON content as a string.
options YamlWriterOptions Optional YAML writer options. (optional)

Returns

string

A string containing the YAML representation of the JSON content.

Applies To

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

ConvertToYamlString(ReadOnlySpan<byte>, YamlWriterOptions)

Converts UTF-8 JSON bytes to a YAML string.

public static string ConvertToYamlString(ReadOnlySpan<byte> utf8Json, YamlWriterOptions options)

Parameters

Name Type Description
utf8Json ReadOnlySpan<byte> The UTF-8 encoded JSON bytes.
options YamlWriterOptions Optional YAML writer options. (optional)

Returns

string

A string containing the YAML representation of the JSON content.

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