Table of Contents

Class JsonTextWriter

Namespace
Newtonsoft.Json
Assembly
Newtonsoft.Json.dll

Represents a writer that provides a fast, non-cached, forward-only way of generating Json data.

public class JsonTextWriter : JsonWriter, IDisposable
Inheritance
JsonTextWriter
Implements
Inherited Members

Constructors

JsonTextWriter(TextWriter)

Creates an instance of the JsonWriter class using the specified TextWriter.

public JsonTextWriter(TextWriter textWriter)

Parameters

textWriter TextWriter

The TextWriter to write to.

Properties

IndentChar

Gets or sets which character to use for indenting when Formatting is set to Formatting.Indented.

public char IndentChar { get; set; }

Property Value

char

Indentation

Gets or sets how many IndentChars to write for each level in the hierarchy when Formatting is set to Formatting.Indented.

public int Indentation { get; set; }

Property Value

int

QuoteChar

Gets or sets which character to use to quote attribute values.

public char QuoteChar { get; set; }

Property Value

char

QuoteName

Gets or sets a value indicating whether object names will be surrounded with quotes.

public bool QuoteName { get; set; }

Property Value

bool

Methods

Close()

Closes this stream and the underlying stream.

public override void Close()

Flush()

Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.

public override void Flush()

WriteComment(string)

Writes out a comment

/.../
containing the specified text.
public override void WriteComment(string text)

Parameters

text string

Text to place inside the comment.

WriteEnd(JsonToken)

Writes the specified end token.

protected override void WriteEnd(JsonToken token)

Parameters

token JsonToken

The end token to write.

WriteIndent()

Writes indent characters.

protected override void WriteIndent()

WriteIndentSpace()

Writes an indent space.

protected override void WriteIndentSpace()

WriteNull()

Writes a null value.

public override void WriteNull()

WritePropertyName(string)

Writes the property name of a name/value pair on a Json object.

public override void WritePropertyName(string name)

Parameters

name string

The name of the property.

WriteRaw(string)

Writes raw JSON.

public override void WriteRaw(string json)

Parameters

json string

The raw JSON to write.

WriteStartArray()

Writes the beginning of a Json array.

public override void WriteStartArray()

WriteStartConstructor(string)

Writes the start of a constructor with the given name.

public override void WriteStartConstructor(string name)

Parameters

name string

The name of the constructor.

WriteStartObject()

Writes the beginning of a Json object.

public override void WriteStartObject()

WriteUndefined()

Writes an undefined value.

public override void WriteUndefined()

WriteValue(bool)

Writes a bool value.

public override void WriteValue(bool value)

Parameters

value bool

The bool value to write.

WriteValue(byte)

Writes a byte value.

public override void WriteValue(byte value)

Parameters

value byte

The byte value to write.

WriteValue(byte[])

Writes a Byte[] value.

public override void WriteValue(byte[] value)

Parameters

value byte[]

The Byte[] value to write.

WriteValue(char)

Writes a char value.

public override void WriteValue(char value)

Parameters

value char

The char value to write.

WriteValue(DateTime)

Writes a DateTime value.

public override void WriteValue(DateTime value)

Parameters

value DateTime

The DateTime value to write.

WriteValue(DateTimeOffset)

Writes a DateTimeOffset value.

public override void WriteValue(DateTimeOffset value)

Parameters

value DateTimeOffset

The DateTimeOffset value to write.

WriteValue(decimal)

Writes a decimal value.

public override void WriteValue(decimal value)

Parameters

value decimal

The decimal value to write.

WriteValue(double)

Writes a double value.

public override void WriteValue(double value)

Parameters

value double

The double value to write.

WriteValue(Guid)

Writes a Guid value.

public override void WriteValue(Guid value)

Parameters

value Guid

The Guid value to write.

WriteValue(short)

Writes a short value.

public override void WriteValue(short value)

Parameters

value short

The short value to write.

WriteValue(int)

Writes a int value.

public override void WriteValue(int value)

Parameters

value int

The int value to write.

WriteValue(long)

Writes a long value.

public override void WriteValue(long value)

Parameters

value long

The long value to write.

WriteValue(sbyte)

Writes a sbyte value.

[CLSCompliant(false)]
public override void WriteValue(sbyte value)

Parameters

value sbyte

The sbyte value to write.

WriteValue(float)

Writes a float value.

public override void WriteValue(float value)

Parameters

value float

The float value to write.

WriteValue(string)

Writes a string value.

public override void WriteValue(string value)

Parameters

value string

The string value to write.

WriteValue(TimeSpan)

Writes a TimeSpan value.

public override void WriteValue(TimeSpan value)

Parameters

value TimeSpan

The TimeSpan value to write.

WriteValue(ushort)

Writes a ushort value.

[CLSCompliant(false)]
public override void WriteValue(ushort value)

Parameters

value ushort

The ushort value to write.

WriteValue(uint)

Writes a uint value.

[CLSCompliant(false)]
public override void WriteValue(uint value)

Parameters

value uint

The uint value to write.

WriteValue(ulong)

Writes a ulong value.

[CLSCompliant(false)]
public override void WriteValue(ulong value)

Parameters

value ulong

The ulong value to write.

WriteValue(Uri)

Writes a System.Uri value.

public override void WriteValue(Uri value)

Parameters

value Uri

The System.Uri value to write.

WriteValueDelimiter()

Writes the JSON value delimiter.

protected override void WriteValueDelimiter()

WriteWhitespace(string)

Writes out the given white space.

public override void WriteWhitespace(string ws)

Parameters

ws string

The string of white space characters.