Utf8JsonWriter.WriteStartObject 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

WriteStartObject(JsonEncodedText)

Writes the beginning of a JSON object with a pre-encoded property name as the key.

WriteStartObject(ReadOnlySpan<Char>)

Writes the beginning of a JSON object with a property name specified as a read-only character span as the key.

WriteStartObject(String)

Writes the beginning of a JSON object with a property name specified as a string as the key.

WriteStartObject()

Writes the beginning of a JSON object.

WriteStartObject(ReadOnlySpan<Byte>)

Writes the beginning of a JSON object with a property name specified as a read-only span of bytes as the key.

WriteStartObject(JsonEncodedText)

Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs

Writes the beginning of a JSON object with a pre-encoded property name as the key.

C#
public void WriteStartObject(System.Text.Json.JsonEncodedText propertyName);

Parameters

propertyName
JsonEncodedText

The JSON encoded property name of the JSON object to be transcoded and written as UTF-8.

Exceptions

The depth of the JSON has exceeded the maximum depth of 1,000.

-or-

Validation is enabled, and this method would result in writing invalid JSON.

Remarks

The property name 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)

WriteStartObject(ReadOnlySpan<Char>)

Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs

Writes the beginning of a JSON object with a property name specified as a read-only character span as the key.

C#
public void WriteStartObject(ReadOnlySpan<char> propertyName);

Parameters

propertyName
ReadOnlySpan<Char>

The UTF-16 encoded property name of the JSON object to be transcoded and written as UTF-8.

Exceptions

The specified property name is too large.

The depth of the JSON exceeds the maximum depth of 1,000.

-or-

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

Remarks

The property name 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)

WriteStartObject(String)

Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs

Writes the beginning of a JSON object with a property name specified as a string as the key.

C#
public void WriteStartObject(string propertyName);

Parameters

propertyName
String

The UTF-16 encoded property name of the JSON object to be transcoded and written as UTF-8.

Exceptions

The specified property name is too large.

The depth of the JSON exceeds the maximum depth of 1,000.

-or-

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

The propertyName parameter is null.

Remarks

The property name 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)

WriteStartObject()

Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs

Writes the beginning of a JSON object.

C#
public void WriteStartObject();

Exceptions

The depth of the JSON exceeds the maximum depth of 1,000.

-or-

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

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)

WriteStartObject(ReadOnlySpan<Byte>)

Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs
Source:
Utf8JsonWriter.cs

Writes the beginning of a JSON object with a property name specified as a read-only span of bytes as the key.

C#
public void WriteStartObject(ReadOnlySpan<byte> utf8PropertyName);

Parameters

utf8PropertyName
ReadOnlySpan<Byte>

The UTF-8 encoded property name of the JSON object to be written.

Exceptions

The specified property name is too large.

The depth of the JSON exceeds the maximum depth of 1,000.

-or-

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

Remarks

The property name 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)