Newtonsoft.Json by James Newton-King

<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />

 JsonWriter

public abstract class JsonWriter : IDisposable
Represents a writer that provides a fast, non-cached, forward-only way of generating JSON data.
public bool AutoCompleteOnClose { get; set; }

Gets or sets a value indicating whether the JSON should be auto-completed when this writer is closed.

public bool CloseOutput { get; set; }

Gets or sets a value indicating whether the destination should be closed when this writer is closed.

public CultureInfo Culture { get; set; }

Gets or sets the culture used when writing JSON. Defaults to InvariantCulture.

Gets or sets how dates are written to JSON text.

public string DateFormatString { get; set; }

Gets or sets how DateTime and DateTimeOffset values are formatted when writing JSON text.

Gets or sets how DateTime time zones are handled when writing JSON text.

Gets or sets how special floating point numbers, e.g. NaN, PositiveInfinity and NegativeInfinity, are written to JSON text.

public Formatting Formatting { get; set; }

Gets or sets a value indicating how JSON text output should be formatted.

public string Path { get; }

Gets the path of the writer.

Gets or sets how strings are escaped when writing JSON text.

public WriteState WriteState { get; }

Gets the state of the writer.

protected JsonWriter()

Initializes a new instance of the JsonWriter class.

public virtual void Close()

Closes this writer. If CloseOutput is set to true, the destination is also closed. If AutoCompleteOnClose is set to true, the JSON is auto-completed.

public virtual Task CloseAsync(CancellationToken cancellationToken = default)

Asynchronously closes this writer. If CloseOutput is set to true, the destination is also closed.

protected virtual void Dispose(bool disposing)

Releases unmanaged and - optionally - managed resources.

public abstract void Flush()

Flushes whatever is in the buffer to the destination and also flushes the destination.

public virtual Task FlushAsync(CancellationToken cancellationToken = default)

Asynchronously flushes whatever is in the buffer to the destination and also flushes the destination.

protected void SetWriteState(JsonToken token, object value)

Sets the state of the JsonWriter.

protected Task SetWriteStateAsync(JsonToken token, object value, CancellationToken cancellationToken)

Asynchronously ets the state of the JsonWriter.

public virtual void WriteComment(string text)

Writes a comment /*...*/ containing the specified text.

public virtual Task WriteCommentAsync(string text, CancellationToken cancellationToken = default)

Asynchronously writes a comment /*...*/ containing the specified text.

public virtual void WriteEnd()

Writes the end of the current JSON object or array.

protected virtual void WriteEnd(JsonToken token)

Writes the specified end token.

public virtual void WriteEndArray()

Writes the end of an array.

public virtual Task WriteEndArrayAsync(CancellationToken cancellationToken = default)

Asynchronously writes the end of an array.

protected virtual Task WriteEndAsync(JsonToken token, CancellationToken cancellationToken)

Asynchronously writes the specified end token.

public virtual Task WriteEndAsync(CancellationToken cancellationToken = default)

Asynchronously writes the end of the current JSON object or array.

public virtual void WriteEndConstructor()

Writes the end constructor.

public virtual Task WriteEndConstructorAsync(CancellationToken cancellationToken = default)

Asynchronously writes the end of a constructor.

public virtual void WriteEndObject()

Writes the end of a JSON object.

public virtual Task WriteEndObjectAsync(CancellationToken cancellationToken = default)

Asynchronously writes the end of a JSON object.

protected virtual void WriteIndent()

Writes indent characters.

protected virtual Task WriteIndentAsync(CancellationToken cancellationToken)

Asynchronously writes indent characters.

protected virtual void WriteIndentSpace()

Writes an indent space.

protected virtual Task WriteIndentSpaceAsync(CancellationToken cancellationToken)

Asynchronously writes an indent space.

public virtual void WriteNull()

Writes a null value.

public virtual Task WriteNullAsync(CancellationToken cancellationToken = default)

Asynchronously writes a null value.

public virtual void WritePropertyName(string name)

Writes the property name of a name/value pair of a JSON object.

public virtual void WritePropertyName(string name, bool escape)

Writes the property name of a name/value pair of a JSON object.

public virtual Task WritePropertyNameAsync(string name, CancellationToken cancellationToken = default)

Asynchronously writes the property name of a name/value pair of a JSON object.

public virtual Task WritePropertyNameAsync(string name, bool escape, CancellationToken cancellationToken = default)

Asynchronously writes the property name of a name/value pair of a JSON object.

public virtual void WriteRaw(string json)

Writes raw JSON without changing the writer's state.

public virtual Task WriteRawAsync(string json, CancellationToken cancellationToken = default)

Asynchronously writes raw JSON without changing the writer's state.

public virtual void WriteRawValue(string json)

Writes raw JSON where a value is expected and updates the writer's state.

public virtual Task WriteRawValueAsync(string json, CancellationToken cancellationToken = default)

Asynchronously writes raw JSON where a value is expected and updates the writer's state.

public virtual void WriteStartArray()

Writes the beginning of a JSON array.

public virtual Task WriteStartArrayAsync(CancellationToken cancellationToken = default)

Asynchronously writes the beginning of a JSON array.

public virtual void WriteStartConstructor(string name)

Writes the start of a constructor with the given name.

public virtual Task WriteStartConstructorAsync(string name, CancellationToken cancellationToken = default)

Asynchronously writes the start of a constructor with the given name.

public virtual void WriteStartObject()

Writes the beginning of a JSON object.

public virtual Task WriteStartObjectAsync(CancellationToken cancellationToken = default)

Asynchronously writes the beginning of a JSON object.

public void WriteToken(JsonReader reader)

Writes the current JsonReader token and its children.

public void WriteToken(JsonReader reader, bool writeChildren)

Writes the current JsonReader token.

public void WriteToken(JsonToken token, object value)

Writes the JsonToken token and its value.

public void WriteToken(JsonToken token)

Writes the JsonToken token.

public Task WriteTokenAsync(JsonReader reader, CancellationToken cancellationToken = default)

Asynchronously writes the current JsonReader token.

public Task WriteTokenAsync(JsonReader reader, bool writeChildren, CancellationToken cancellationToken = default)

Asynchronously writes the current JsonReader token.

public Task WriteTokenAsync(JsonToken token, CancellationToken cancellationToken = default)

Asynchronously writes the JsonToken token and its value.

public Task WriteTokenAsync(JsonToken token, object value, CancellationToken cancellationToken = default)

Asynchronously writes the JsonToken token and its value.

public virtual void WriteUndefined()

Writes an undefined value.

public virtual Task WriteUndefinedAsync(CancellationToken cancellationToken = default)

Asynchronously writes an undefined value.

public virtual void WriteValue(string value)

Writes a String value.

public virtual void WriteValue(int value)

Writes a Int32 value.

public virtual void WriteValue(uint value)

Writes a UInt32 value.

public virtual void WriteValue(long value)

Writes a Int64 value.

public virtual void WriteValue(ulong value)

Writes a UInt64 value.

public virtual void WriteValue(float value)

Writes a Single value.

public virtual void WriteValue(double value)

Writes a Double value.

public virtual void WriteValue(bool value)

Writes a Boolean value.

public virtual void WriteValue(short value)

Writes a Int16 value.

public virtual void WriteValue(ushort value)

Writes a UInt16 value.

public virtual void WriteValue(char value)

Writes a Char value.

public virtual void WriteValue(byte value)

Writes a Byte value.

public virtual void WriteValue(sbyte value)

Writes a SByte value.

public virtual void WriteValue(decimal value)

Writes a Decimal value.

public virtual void WriteValue(DateTime value)

Writes a DateTime value.

public virtual void WriteValue(DateTimeOffset value)

Writes a DateTimeOffset value.

public virtual void WriteValue(Guid value)

Writes a Guid value.

public virtual void WriteValue(TimeSpan value)

Writes a TimeSpan value.

public virtual void WriteValue(int? value)

Writes a Nullable<T> of Int32 value.

public virtual void WriteValue(uint? value)

Writes a Nullable<T> of UInt32 value.

public virtual void WriteValue(long? value)

Writes a Nullable<T> of Int64 value.

public virtual void WriteValue(ulong? value)

Writes a Nullable<T> of UInt64 value.

public virtual void WriteValue(float? value)

Writes a Nullable<T> of Single value.

public virtual void WriteValue(double? value)

Writes a Nullable<T> of Double value.

public virtual void WriteValue(bool? value)

Writes a Nullable<T> of Boolean value.

public virtual void WriteValue(short? value)

Writes a Nullable<T> of Int16 value.

public virtual void WriteValue(ushort? value)

Writes a Nullable<T> of UInt16 value.

public virtual void WriteValue(char? value)

Writes a Nullable<T> of Char value.

public virtual void WriteValue(byte? value)

Writes a Nullable<T> of Byte value.

public virtual void WriteValue(sbyte? value)

Writes a Nullable<T> of SByte value.

public virtual void WriteValue(decimal? value)

Writes a Nullable<T> of Decimal value.

public virtual void WriteValue(DateTime? value)

Writes a Nullable<T> of DateTime value.

public virtual void WriteValue(DateTimeOffset? value)

Writes a Nullable<T> of DateTimeOffset value.

public virtual void WriteValue(Guid? value)

Writes a Nullable<T> of Guid value.

public virtual void WriteValue(TimeSpan? value)

Writes a Nullable<T> of TimeSpan value.

public virtual void WriteValue(byte[] value)

Writes a Byte[] value.

public virtual void WriteValue(Uri value)

Writes a Uri value.

public virtual void WriteValue(object value)

Writes a Object value. An error will raised if the value cannot be written as a single JSON token.

public virtual Task WriteValueAsync(bool value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of Boolean value.

public virtual Task WriteValueAsync(bool? value, CancellationToken cancellationToken = default)

Asynchronously writes a Boolean value.

public virtual Task WriteValueAsync(byte value, CancellationToken cancellationToken = default)

Asynchronously writes a Byte value.

public virtual Task WriteValueAsync(byte? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of Byte value.

public virtual Task WriteValueAsync(byte[] value, CancellationToken cancellationToken = default)

Asynchronously writes a Byte[] value.

public virtual Task WriteValueAsync(char value, CancellationToken cancellationToken = default)

Asynchronously writes a Char value.

public virtual Task WriteValueAsync(char? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of Char value.

public virtual Task WriteValueAsync(DateTime value, CancellationToken cancellationToken = default)

Asynchronously writes a DateTime value.

public virtual Task WriteValueAsync(DateTime? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of DateTime value.

public virtual Task WriteValueAsync(DateTimeOffset value, CancellationToken cancellationToken = default)

Asynchronously writes a DateTimeOffset value.

public virtual Task WriteValueAsync(DateTimeOffset? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of DateTimeOffset value.

public virtual Task WriteValueAsync(decimal value, CancellationToken cancellationToken = default)

Asynchronously writes a Decimal value.

public virtual Task WriteValueAsync(decimal? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of Decimal value.

public virtual Task WriteValueAsync(double value, CancellationToken cancellationToken = default)

Asynchronously writes a Double value.

public virtual Task WriteValueAsync(double? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of Double value.

public virtual Task WriteValueAsync(float value, CancellationToken cancellationToken = default)

Asynchronously writes a Single value.

public virtual Task WriteValueAsync(float? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of Single value.

public virtual Task WriteValueAsync(Guid value, CancellationToken cancellationToken = default)

Asynchronously writes a Guid value.

public virtual Task WriteValueAsync(Guid? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of Guid value.

public virtual Task WriteValueAsync(int value, CancellationToken cancellationToken = default)

Asynchronously writes a Int32 value.

public virtual Task WriteValueAsync(int? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of Int32 value.

public virtual Task WriteValueAsync(long value, CancellationToken cancellationToken = default)

Asynchronously writes a Int64 value.

public virtual Task WriteValueAsync(long? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of Int64 value.

public virtual Task WriteValueAsync(object value, CancellationToken cancellationToken = default)

Asynchronously writes a Object value.

public virtual Task WriteValueAsync(sbyte value, CancellationToken cancellationToken = default)

Asynchronously writes a SByte value.

public virtual Task WriteValueAsync(sbyte? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of SByte value.

public virtual Task WriteValueAsync(short value, CancellationToken cancellationToken = default)

Asynchronously writes a Int16 value.

public virtual Task WriteValueAsync(short? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of Int16 value.

public virtual Task WriteValueAsync(string value, CancellationToken cancellationToken = default)

Asynchronously writes a String value.

public virtual Task WriteValueAsync(TimeSpan value, CancellationToken cancellationToken = default)

Asynchronously writes a TimeSpan value.

public virtual Task WriteValueAsync(TimeSpan? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of TimeSpan value.

public virtual Task WriteValueAsync(uint value, CancellationToken cancellationToken = default)

Asynchronously writes a UInt32 value.

public virtual Task WriteValueAsync(uint? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of UInt32 value.

public virtual Task WriteValueAsync(ulong value, CancellationToken cancellationToken = default)

Asynchronously writes a UInt64 value.

public virtual Task WriteValueAsync(ulong? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of UInt64 value.

public virtual Task WriteValueAsync(Uri value, CancellationToken cancellationToken = default)

Asynchronously writes a Uri value.

public virtual Task WriteValueAsync(ushort value, CancellationToken cancellationToken = default)

Asynchronously writes a UInt16 value.

public virtual Task WriteValueAsync(ushort? value, CancellationToken cancellationToken = default)

Asynchronously writes a Nullable<T> of UInt16 value.

protected virtual void WriteValueDelimiter()

Writes the JSON value delimiter.

protected virtual Task WriteValueDelimiterAsync(CancellationToken cancellationToken)

Asynchronously writes the JSON value delimiter.

public virtual void WriteWhitespace(string ws)

Writes the given white space.

public virtual Task WriteWhitespaceAsync(string ws, CancellationToken cancellationToken = default)

Asynchronously writes the given white space.