Utf8JsonWriter Utf8JsonWriter Utf8JsonWriter Utf8JsonWriter Struct

Definition

Provides a high-performance API for forward-only, non-cached writing of UTF-8 encoded JSON text.

public value class Utf8JsonWriter
public struct Utf8JsonWriter
type Utf8JsonWriter = struct
Public Structure Utf8JsonWriter
Inheritance
Utf8JsonWriterUtf8JsonWriterUtf8JsonWriterUtf8JsonWriter

Remarks

Utf8JsonWriter writes the text sequentially with no caching and by default adheres to the JSON RFC, with the exception of writing comments.

A method that attempts to write invalid JSON when validation is enabled throws a InvalidOperationException with a context-specific error message. Since this type is a ref struct, it does not directly support async. However, it does provide support for reentrancy to write partial data and to continue writing in chunks. To be able to format the output with indentation and white space OR to skip validation, create an instance of JsonWriterState and pass that in to the writer.

Constructors

Utf8JsonWriter(IBufferWriter<Byte>, JsonWriterState) Utf8JsonWriter(IBufferWriter<Byte>, JsonWriterState) Utf8JsonWriter(IBufferWriter<Byte>, JsonWriterState) Utf8JsonWriter(IBufferWriter<Byte>, JsonWriterState)

Initializes a new instance of the Utf8JsonWriter class with the specified bufferWriter.

Properties

BytesCommitted BytesCommitted BytesCommitted BytesCommitted

Gets the total number of bytes committed to the output by the Utf8JsonWriter so far for the current instance of the Utf8JsonWriter. This indicates how much the IBufferWriter<T> has advanced.

BytesWritten BytesWritten BytesWritten BytesWritten

Gets the total number of bytes written by the Utf8JsonWriter so far for the current instance of the Utf8JsonWriter. This includes data that has been written beyond what has already been committed.

CurrentDepth CurrentDepth CurrentDepth CurrentDepth

Gets the depth of the current token.

Methods

Flush(Boolean) Flush(Boolean) Flush(Boolean) Flush(Boolean)

Advances the underlying IBufferWriter<T> based on what has been written so far.

GetCurrentState() GetCurrentState() GetCurrentState() GetCurrentState()

Returns the current snapshot of the Utf8JsonWriter state that must be captured by the caller and passed back in to the Utf8JsonWriter constructor with more data.

WriteBoolean(ReadOnlySpan<Byte>, Boolean, Boolean) WriteBoolean(ReadOnlySpan<Byte>, Boolean, Boolean) WriteBoolean(ReadOnlySpan<Byte>, Boolean, Boolean) WriteBoolean(ReadOnlySpan<Byte>, Boolean, Boolean)

Writes the property name and Boolean value (as a JSON literal "true" or "false") as part of a name/value pair of a JSON object.

WriteBoolean(ReadOnlySpan<Char>, Boolean, Boolean) WriteBoolean(ReadOnlySpan<Char>, Boolean, Boolean) WriteBoolean(ReadOnlySpan<Char>, Boolean, Boolean) WriteBoolean(ReadOnlySpan<Char>, Boolean, Boolean)

Writes the property name and Boolean value (as a JSON literal "true" or "false") as part of a name/value pair of a JSON object.

WriteBoolean(String, Boolean, Boolean) WriteBoolean(String, Boolean, Boolean) WriteBoolean(String, Boolean, Boolean) WriteBoolean(String, Boolean, Boolean)

Writes the property name and Boolean value (as a JSON literal "true" or "false") as part of a name/value pair of a JSON object.

WriteBooleanValue(Boolean) WriteBooleanValue(Boolean) WriteBooleanValue(Boolean) WriteBooleanValue(Boolean)

Writes the Boolean value (as a JSON literal "true" or "false") as an element of a JSON array.

WriteCommentValue(ReadOnlySpan<Byte>, Boolean) WriteCommentValue(ReadOnlySpan<Byte>, Boolean) WriteCommentValue(ReadOnlySpan<Byte>, Boolean) WriteCommentValue(ReadOnlySpan<Byte>, Boolean)

Writes the UTF-8 text value as a JSON comment (within /../).

WriteCommentValue(ReadOnlySpan<Char>, Boolean) WriteCommentValue(ReadOnlySpan<Char>, Boolean) WriteCommentValue(ReadOnlySpan<Char>, Boolean) WriteCommentValue(ReadOnlySpan<Char>, Boolean)

Writes the UTF-16 text value as a JSON comment (within /../).

WriteCommentValue(String, Boolean) WriteCommentValue(String, Boolean) WriteCommentValue(String, Boolean) WriteCommentValue(String, Boolean)

Writes the string text value as a JSON comment (within /../).

WriteEndArray() WriteEndArray() WriteEndArray() WriteEndArray()

Writes the end of a JSON array.

WriteEndObject() WriteEndObject() WriteEndObject() WriteEndObject()

Writes the end of a JSON object.

WriteNull(ReadOnlySpan<Byte>, Boolean) WriteNull(ReadOnlySpan<Byte>, Boolean) WriteNull(ReadOnlySpan<Byte>, Boolean) WriteNull(ReadOnlySpan<Byte>, Boolean)

Writes the property name and the JSON literal "null" as part of a name/value pair of a JSON object.

WriteNull(ReadOnlySpan<Char>, Boolean) WriteNull(ReadOnlySpan<Char>, Boolean) WriteNull(ReadOnlySpan<Char>, Boolean) WriteNull(ReadOnlySpan<Char>, Boolean)

Writes the property name and the JSON literal "null" as part of a name/value pair of a JSON object.

WriteNull(String, Boolean) WriteNull(String, Boolean) WriteNull(String, Boolean) WriteNull(String, Boolean)

Writes the property name and the JSON literal "null" as part of a name/value pair of a JSON object.

WriteNullValue() WriteNullValue() WriteNullValue() WriteNullValue()

Writes the JSON literal "null" as an element of a JSON array.

WriteNumber(String, UInt32, Boolean) WriteNumber(String, UInt32, Boolean) WriteNumber(String, UInt32, Boolean) WriteNumber(String, UInt32, Boolean)

Writes the property name and UInt32 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(String, Single, Boolean) WriteNumber(String, Single, Boolean) WriteNumber(String, Single, Boolean) WriteNumber(String, Single, Boolean)

Writes the property name and Single value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(String, Int64, Boolean) WriteNumber(String, Int64, Boolean) WriteNumber(String, Int64, Boolean) WriteNumber(String, Int64, Boolean)

Writes the property name and Int64 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(String, Int32, Boolean) WriteNumber(String, Int32, Boolean) WriteNumber(String, Int32, Boolean) WriteNumber(String, Int32, Boolean)

Writes the property name and Int32 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(String, Double, Boolean) WriteNumber(String, Double, Boolean) WriteNumber(String, Double, Boolean) WriteNumber(String, Double, Boolean)

Writes the property name and Double value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(String, Decimal, Boolean) WriteNumber(String, Decimal, Boolean) WriteNumber(String, Decimal, Boolean) WriteNumber(String, Decimal, Boolean)

Writes the property name and Decimal value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Char>, UInt64, Boolean) WriteNumber(ReadOnlySpan<Char>, UInt64, Boolean) WriteNumber(ReadOnlySpan<Char>, UInt64, Boolean) WriteNumber(ReadOnlySpan<Char>, UInt64, Boolean)

Writes the property name and UInt64 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Char>, UInt32, Boolean) WriteNumber(ReadOnlySpan<Char>, UInt32, Boolean) WriteNumber(ReadOnlySpan<Char>, UInt32, Boolean) WriteNumber(ReadOnlySpan<Char>, UInt32, Boolean)

Writes the property name and UInt32 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Char>, Single, Boolean) WriteNumber(ReadOnlySpan<Char>, Single, Boolean) WriteNumber(ReadOnlySpan<Char>, Single, Boolean) WriteNumber(ReadOnlySpan<Char>, Single, Boolean)

Writes the property name and Single value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Char>, Int64, Boolean) WriteNumber(ReadOnlySpan<Char>, Int64, Boolean) WriteNumber(ReadOnlySpan<Char>, Int64, Boolean) WriteNumber(ReadOnlySpan<Char>, Int64, Boolean)

Writes the property name and Int64 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(String, UInt64, Boolean) WriteNumber(String, UInt64, Boolean) WriteNumber(String, UInt64, Boolean) WriteNumber(String, UInt64, Boolean)

Writes the property name and UInt64 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Char>, Double, Boolean) WriteNumber(ReadOnlySpan<Char>, Double, Boolean) WriteNumber(ReadOnlySpan<Char>, Double, Boolean) WriteNumber(ReadOnlySpan<Char>, Double, Boolean)

Writes the property name and Double value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Char>, Decimal, Boolean) WriteNumber(ReadOnlySpan<Char>, Decimal, Boolean) WriteNumber(ReadOnlySpan<Char>, Decimal, Boolean) WriteNumber(ReadOnlySpan<Char>, Decimal, Boolean)

Writes the property name and Decimal value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Byte>, UInt64, Boolean) WriteNumber(ReadOnlySpan<Byte>, UInt64, Boolean) WriteNumber(ReadOnlySpan<Byte>, UInt64, Boolean) WriteNumber(ReadOnlySpan<Byte>, UInt64, Boolean)

Writes the property name and UInt64 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Byte>, UInt32, Boolean) WriteNumber(ReadOnlySpan<Byte>, UInt32, Boolean) WriteNumber(ReadOnlySpan<Byte>, UInt32, Boolean) WriteNumber(ReadOnlySpan<Byte>, UInt32, Boolean)

Writes the property name and UInt32 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Byte>, Single, Boolean) WriteNumber(ReadOnlySpan<Byte>, Single, Boolean) WriteNumber(ReadOnlySpan<Byte>, Single, Boolean) WriteNumber(ReadOnlySpan<Byte>, Single, Boolean)

Writes the property name and Single value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Byte>, Int64, Boolean) WriteNumber(ReadOnlySpan<Byte>, Int64, Boolean) WriteNumber(ReadOnlySpan<Byte>, Int64, Boolean) WriteNumber(ReadOnlySpan<Byte>, Int64, Boolean)

Writes the property name and Int64 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Byte>, Int32, Boolean) WriteNumber(ReadOnlySpan<Byte>, Int32, Boolean) WriteNumber(ReadOnlySpan<Byte>, Int32, Boolean) WriteNumber(ReadOnlySpan<Byte>, Int32, Boolean)

Writes the property name and Int32 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Byte>, Double, Boolean) WriteNumber(ReadOnlySpan<Byte>, Double, Boolean) WriteNumber(ReadOnlySpan<Byte>, Double, Boolean) WriteNumber(ReadOnlySpan<Byte>, Double, Boolean)

Writes the property name and Double value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Byte>, Decimal, Boolean) WriteNumber(ReadOnlySpan<Byte>, Decimal, Boolean) WriteNumber(ReadOnlySpan<Byte>, Decimal, Boolean) WriteNumber(ReadOnlySpan<Byte>, Decimal, Boolean)

Writes the property name and Decimal value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumber(ReadOnlySpan<Char>, Int32, Boolean) WriteNumber(ReadOnlySpan<Char>, Int32, Boolean) WriteNumber(ReadOnlySpan<Char>, Int32, Boolean) WriteNumber(ReadOnlySpan<Char>, Int32, Boolean)

Writes the property name and Int32 value (as a JSON number) as part of a name/value pair of a JSON object.

WriteNumberValue(UInt64) WriteNumberValue(UInt64) WriteNumberValue(UInt64) WriteNumberValue(UInt64)

Writes the UInt64 value (as a JSON number) as an element of a JSON array.

WriteNumberValue(UInt32) WriteNumberValue(UInt32) WriteNumberValue(UInt32) WriteNumberValue(UInt32)

Writes the UInt32 value (as a JSON number) as an element of a JSON array.

WriteNumberValue(Single) WriteNumberValue(Single) WriteNumberValue(Single) WriteNumberValue(Single)

Writes the Single value (as a JSON number) as an element of a JSON array.

WriteNumberValue(Decimal) WriteNumberValue(Decimal) WriteNumberValue(Decimal) WriteNumberValue(Decimal)

Writes the Decimal value (as a JSON number) as an element of a JSON array.

WriteNumberValue(Int32) WriteNumberValue(Int32) WriteNumberValue(Int32) WriteNumberValue(Int32)

Writes the Int32 value (as a JSON number) as an element of a JSON array.

WriteNumberValue(Double) WriteNumberValue(Double) WriteNumberValue(Double) WriteNumberValue(Double)

Writes the Double value (as a JSON number) as an element of a JSON array.

WriteNumberValue(Int64) WriteNumberValue(Int64) WriteNumberValue(Int64) WriteNumberValue(Int64)

Writes the Int64 value (as a JSON number) as an element of a JSON array.

WriteStartArray(String, Boolean) WriteStartArray(String, Boolean) WriteStartArray(String, Boolean) WriteStartArray(String, Boolean)

Writes the beginning of a JSON array with a property name as the key.

WriteStartArray() WriteStartArray() WriteStartArray() WriteStartArray()

Writes the beginning of a JSON array.

WriteStartArray(ReadOnlySpan<Byte>, Boolean) WriteStartArray(ReadOnlySpan<Byte>, Boolean) WriteStartArray(ReadOnlySpan<Byte>, Boolean) WriteStartArray(ReadOnlySpan<Byte>, Boolean)

Writes the beginning of a JSON array with a property name as the key.

WriteStartArray(ReadOnlySpan<Char>, Boolean) WriteStartArray(ReadOnlySpan<Char>, Boolean) WriteStartArray(ReadOnlySpan<Char>, Boolean) WriteStartArray(ReadOnlySpan<Char>, Boolean)

Writes the beginning of a JSON array with a property name as the key.

WriteStartObject(ReadOnlySpan<Char>, Boolean) WriteStartObject(ReadOnlySpan<Char>, Boolean) WriteStartObject(ReadOnlySpan<Char>, Boolean) WriteStartObject(ReadOnlySpan<Char>, Boolean)

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

WriteStartObject(String, Boolean) WriteStartObject(String, Boolean) WriteStartObject(String, Boolean) WriteStartObject(String, Boolean)

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

WriteStartObject() WriteStartObject() WriteStartObject() WriteStartObject()

Writes the beginning of a JSON object.

WriteStartObject(ReadOnlySpan<Byte>, Boolean) WriteStartObject(ReadOnlySpan<Byte>, Boolean) WriteStartObject(ReadOnlySpan<Byte>, Boolean) WriteStartObject(ReadOnlySpan<Byte>, Boolean)

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

WriteString(String, String, Boolean) WriteString(String, String, Boolean) WriteString(String, String, Boolean) WriteString(String, String, Boolean)

Writes the property name and string text value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(String, ReadOnlySpan<Char>, Boolean) WriteString(String, ReadOnlySpan<Char>, Boolean) WriteString(String, ReadOnlySpan<Char>, Boolean) WriteString(String, ReadOnlySpan<Char>, Boolean)

Writes the property name and UTF-16 text value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(String, ReadOnlySpan<Byte>, Boolean) WriteString(String, ReadOnlySpan<Byte>, Boolean) WriteString(String, ReadOnlySpan<Byte>, Boolean) WriteString(String, ReadOnlySpan<Byte>, Boolean)

Writes the property name and UTF-8 text value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(String, Guid, Boolean) WriteString(String, Guid, Boolean) WriteString(String, Guid, Boolean) WriteString(String, Guid, Boolean)

Writes the property name and Guid value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(String, DateTimeOffset, Boolean) WriteString(String, DateTimeOffset, Boolean) WriteString(String, DateTimeOffset, Boolean) WriteString(String, DateTimeOffset, Boolean)

Writes the property name and DateTimeOffset value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(String, DateTime, Boolean) WriteString(String, DateTime, Boolean) WriteString(String, DateTime, Boolean) WriteString(String, DateTime, Boolean)

Writes the property name and DateTime value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Char>, String, Boolean) WriteString(ReadOnlySpan<Char>, String, Boolean) WriteString(ReadOnlySpan<Char>, String, Boolean) WriteString(ReadOnlySpan<Char>, String, Boolean)

Writes the UTF-16 property name and string text value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Boolean) WriteString(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Boolean) WriteString(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Boolean) WriteString(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Boolean)

Writes the UTF-16 property name and UTF-8 text value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Char>, ReadOnlySpan<Char>, Boolean) WriteString(ReadOnlySpan<Char>, ReadOnlySpan<Char>, Boolean) WriteString(ReadOnlySpan<Char>, ReadOnlySpan<Char>, Boolean) WriteString(ReadOnlySpan<Char>, ReadOnlySpan<Char>, Boolean)

Writes the UTF-16 property name and UTF-16 text value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Char>, DateTimeOffset, Boolean) WriteString(ReadOnlySpan<Char>, DateTimeOffset, Boolean) WriteString(ReadOnlySpan<Char>, DateTimeOffset, Boolean) WriteString(ReadOnlySpan<Char>, DateTimeOffset, Boolean)

Writes the property name and DateTimeOffset value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Char>, DateTime, Boolean) WriteString(ReadOnlySpan<Char>, DateTime, Boolean) WriteString(ReadOnlySpan<Char>, DateTime, Boolean) WriteString(ReadOnlySpan<Char>, DateTime, Boolean)

Writes the property name and DateTime value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Byte>, String, Boolean) WriteString(ReadOnlySpan<Byte>, String, Boolean) WriteString(ReadOnlySpan<Byte>, String, Boolean) WriteString(ReadOnlySpan<Byte>, String, Boolean)

Writes the UTF-8 property name and string text value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Byte>, ReadOnlySpan<Char>, Boolean) WriteString(ReadOnlySpan<Byte>, ReadOnlySpan<Char>, Boolean) WriteString(ReadOnlySpan<Byte>, ReadOnlySpan<Char>, Boolean) WriteString(ReadOnlySpan<Byte>, ReadOnlySpan<Char>, Boolean)

Writes the UTF-8 property name and UTF-16 text value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Boolean) WriteString(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Boolean) WriteString(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Boolean) WriteString(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Boolean)

Writes the UTF-8 property name and UTF-8 text value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Byte>, Guid, Boolean) WriteString(ReadOnlySpan<Byte>, Guid, Boolean) WriteString(ReadOnlySpan<Byte>, Guid, Boolean) WriteString(ReadOnlySpan<Byte>, Guid, Boolean)

Writes the property name and Guid value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Byte>, DateTimeOffset, Boolean) WriteString(ReadOnlySpan<Byte>, DateTimeOffset, Boolean) WriteString(ReadOnlySpan<Byte>, DateTimeOffset, Boolean) WriteString(ReadOnlySpan<Byte>, DateTimeOffset, Boolean)

Writes the property name and DateTimeOffset value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Byte>, DateTime, Boolean) WriteString(ReadOnlySpan<Byte>, DateTime, Boolean) WriteString(ReadOnlySpan<Byte>, DateTime, Boolean) WriteString(ReadOnlySpan<Byte>, DateTime, Boolean)

Writes the property name and DateTime value (as a JSON string) as part of a name/value pair of a JSON object.

WriteString(ReadOnlySpan<Char>, Guid, Boolean) WriteString(ReadOnlySpan<Char>, Guid, Boolean) WriteString(ReadOnlySpan<Char>, Guid, Boolean) WriteString(ReadOnlySpan<Char>, Guid, Boolean)

Writes the property name and Guid value (as a JSON string) as part of a name/value pair of a JSON object.

WriteStringValue(ReadOnlySpan<Char>, Boolean) WriteStringValue(ReadOnlySpan<Char>, Boolean) WriteStringValue(ReadOnlySpan<Char>, Boolean) WriteStringValue(ReadOnlySpan<Char>, Boolean)

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

WriteStringValue(DateTime) WriteStringValue(DateTime) WriteStringValue(DateTime) WriteStringValue(DateTime)

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

WriteStringValue(DateTimeOffset) WriteStringValue(DateTimeOffset) WriteStringValue(DateTimeOffset) WriteStringValue(DateTimeOffset)

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

WriteStringValue(Guid) WriteStringValue(Guid) WriteStringValue(Guid) WriteStringValue(Guid)

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

WriteStringValue(ReadOnlySpan<Byte>, Boolean) WriteStringValue(ReadOnlySpan<Byte>, Boolean) WriteStringValue(ReadOnlySpan<Byte>, Boolean) WriteStringValue(ReadOnlySpan<Byte>, Boolean)

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

WriteStringValue(String, Boolean) WriteStringValue(String, Boolean) WriteStringValue(String, Boolean) WriteStringValue(String, Boolean)

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

Applies to