Skip to content

Utf8JsonWriter.WriteStringValue Method

Definition

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

Overloads

Method Description
WriteStringValue(DateTime) Writes the DateTime value (as a JSON string) as an element of a JSON array.
WriteStringValue(DateTimeOffset) Writes the DateTimeOffset value (as a JSON string) as an element of a JSON array.
WriteStringValue(Guid) Writes the Guid value (as a JSON string) as an element of a JSON array.
WriteStringValue(JsonEncodedText) Writes the pre-encoded text value (as a JSON string) as an element of a JSON array.
WriteStringValue(string) Writes the string text value (as a JSON string) as an element of a JSON array.
WriteStringValue(ReadOnlySpan<char>) Writes the text value (as a JSON string) as an element of a JSON array.
WriteStringValue(ReadOnlySpan<byte>) Writes the UTF-8 text value (as a JSON string) as an element of a JSON array.

WriteStringValue(DateTime)

Source: Utf8JsonWriter.WriteValues.DateTime.cs

Writes the DateTime value (as a JSON string) as an element of a JSON array.

public void WriteStringValue(DateTime value)

Parameters

Name Type Description
value DateTime The value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

Writes the DateTime using the round-trippable ('O') StandardFormat, for example: 2017-06-12T05:30:45.7680000.

Applies To

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

WriteStringValue(DateTimeOffset)

Source: Utf8JsonWriter.WriteValues.DateTimeOffset.cs

Writes the DateTimeOffset value (as a JSON string) as an element of a JSON array.

public void WriteStringValue(DateTimeOffset value)

Parameters

Name Type Description
value DateTimeOffset The value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

Writes the DateTimeOffset using the round-trippable ('O') StandardFormat, for example: 2017-06-12T05:30:45.7680000-07:00.

Applies To

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

WriteStringValue(Guid)

Source: Utf8JsonWriter.WriteValues.Guid.cs

Writes the Guid value (as a JSON string) as an element of a JSON array.

public void WriteStringValue(Guid value)

Parameters

Name Type Description
value Guid The value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

Writes the Guid using the default StandardFormat (that is, 'D'), as the form: nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn.

Applies To

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

WriteStringValue(JsonEncodedText)

Source: Utf8JsonWriter.WriteValues.String.cs

Writes the pre-encoded text value (as a JSON string) as an element of a JSON array.

public void WriteStringValue(JsonEncodedText value)

Parameters

Name Type Description
value JsonEncodedText The JSON-encoded value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Applies To

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

WriteStringValue(string)

Source: Utf8JsonWriter.WriteValues.String.cs

Writes the string text value (as a JSON string) as an element of a JSON array.

public void WriteStringValue(string value)

Parameters

Name Type Description
value string The value to write.

Exceptions

Exception Description
ArgumentException Thrown when the specified value is too large.
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

The value is escaped before writing. If value is null the JSON null value is written, as if WriteNullValue was called.

Applies To

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

WriteStringValue(ReadOnlySpan<char>)

Source: Utf8JsonWriter.WriteValues.String.cs

Writes the text value (as a JSON string) as an element of a JSON array.

public void WriteStringValue(ReadOnlySpan<char> value)

Parameters

Name Type Description
value ReadOnlySpan<char> The value to write.

Exceptions

Exception Description
ArgumentException Thrown when the specified value is too large.
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

The value is escaped before writing.

Applies To

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

WriteStringValue(ReadOnlySpan<byte>)

Source: Utf8JsonWriter.WriteValues.String.cs

Writes the UTF-8 text value (as a JSON string) as an element of a JSON array.

public void WriteStringValue(ReadOnlySpan<byte> utf8Value)

Parameters

Name Type Description
utf8Value ReadOnlySpan<byte> The UTF-8 encoded value to be written as a JSON string element of a JSON array.

Exceptions

Exception Description
ArgumentException Thrown when the specified value is too large.
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

The value is escaped before writing.

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