Utf8JsonWriter.WriteStringValue Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

WriteStringValue(DateTime)

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

WriteStringValue(DateTimeOffset)

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

WriteStringValue(Guid)

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

WriteStringValue(ReadOnlySpan<Byte>)

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

WriteStringValue(ReadOnlySpan<Char>)

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

WriteStringValue(String)

Writes a string text 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(DateTime)

Source:
Utf8JsonWriter.WriteValues.DateTime.cs
Source:
Utf8JsonWriter.WriteValues.DateTime.cs
Source:
Utf8JsonWriter.WriteValues.DateTime.cs
Source:
Utf8JsonWriter.WriteValues.DateTime.cs
Source:
Utf8JsonWriter.WriteValues.DateTime.cs
Source:
Utf8JsonWriter.WriteValues.DateTime.cs

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

C#
public void WriteStringValue(DateTime value);

Parameters

value
DateTime

The value to be written as a JSON string as an element of a JSON array.

Exceptions

Validation is enabled, and the operation would result in writing invalid JSON.

Remarks

This method writes the DateTime using the ISO 8601-1 extended format (see DateTime and DateTimeOffset support in System.Text.Json); for example, 2017-06-12T05:30:45.7680000.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

WriteStringValue(DateTimeOffset)

Source:
Utf8JsonWriter.WriteValues.DateTimeOffset.cs
Source:
Utf8JsonWriter.WriteValues.DateTimeOffset.cs
Source:
Utf8JsonWriter.WriteValues.DateTimeOffset.cs
Source:
Utf8JsonWriter.WriteValues.DateTimeOffset.cs
Source:
Utf8JsonWriter.WriteValues.DateTimeOffset.cs
Source:
Utf8JsonWriter.WriteValues.DateTimeOffset.cs

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

C#
public void WriteStringValue(DateTimeOffset value);

Parameters

value
DateTimeOffset

The value to be written as a JSON string as an element of a JSON array.

Exceptions

Validation is enabled, and the operation would result in writing invalid JSON.

Remarks

This method writes the DateTimeOffset using the ISO 8601-1 extended format (see DateTime and DateTimeOffset support in System.Text.Json); for example, 2017-06-12T05:30:45.7680000-07:00.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

WriteStringValue(Guid)

Source:
Utf8JsonWriter.WriteValues.Guid.cs
Source:
Utf8JsonWriter.WriteValues.Guid.cs
Source:
Utf8JsonWriter.WriteValues.Guid.cs
Source:
Utf8JsonWriter.WriteValues.Guid.cs
Source:
Utf8JsonWriter.WriteValues.Guid.cs
Source:
Utf8JsonWriter.WriteValues.Guid.cs

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

C#
public void WriteStringValue(Guid value);

Parameters

value
Guid

The value to be written as a JSON string as an element of a JSON array.

Exceptions

Validation is enabled, and the operation would result in writing invalid JSON.

Remarks

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

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

WriteStringValue(ReadOnlySpan<Byte>)

Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs

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

C#
public void WriteStringValue(ReadOnlySpan<byte> utf8Value);

Parameters

utf8Value
ReadOnlySpan<Byte>

The UTF-8 encoded value to be written as a JSON string element of a JSON array.

Exceptions

The specified value is too large.

Validation is enabled, and the write operation would produce invalid JSON.

Remarks

The value is escaped before writing.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

WriteStringValue(ReadOnlySpan<Char>)

Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs

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

C#
public void WriteStringValue(ReadOnlySpan<char> value);

Parameters

value
ReadOnlySpan<Char>

The UTF-16 encoded value to be written as a UTF-8 transcoded JSON string element of a JSON array.

Exceptions

The specified value is too large.

Validation is enabled, and the write operation would produce invalid JSON.

Remarks

The value is escaped before writing.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

WriteStringValue(String)

Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs

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

C#
public void WriteStringValue(string? value);
C#
public void WriteStringValue(string value);

Parameters

value
String

The UTF-16 encoded value to be written as a UTF-8 transcoded JSON string element of a JSON array.

Exceptions

The specified value is too large.

Validation is enabled, and the write operation would produce invalid JSON.

Remarks

The value is escaped before writing.

If value is null, the JSON null value is written, as if the WriteNullValue() method was called.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

WriteStringValue(JsonEncodedText)

Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs
Source:
Utf8JsonWriter.WriteValues.String.cs

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

C#
public void WriteStringValue(System.Text.Json.JsonEncodedText value);

Parameters

value
JsonEncodedText

The JSON encoded value to be written as a UTF-8 transcoded JSON string element of a JSON array.

Exceptions

Validation is enabled, and the write operation would produce invalid JSON.

Remarks

The value should already be escaped when the instance of JsonEncodedText was created.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)