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
TextWriterThe
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
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
QuoteChar
Gets or sets which character to use to quote attribute values.
public char QuoteChar { get; set; }
Property Value
QuoteName
Gets or sets a value indicating whether object names will be surrounded with quotes.
public bool QuoteName { get; set; }
Property Value
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
stringText to place inside the comment.
WriteEnd(JsonToken)
Writes the specified end token.
protected override void WriteEnd(JsonToken token)
Parameters
token
JsonTokenThe 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
stringThe name of the property.
WriteRaw(string)
Writes raw JSON.
public override void WriteRaw(string json)
Parameters
json
stringThe 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
stringThe 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
WriteValue(byte)
Writes a byte value.
public override void WriteValue(byte value)
Parameters
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
WriteValue(DateTime)
Writes a DateTime value.
public override void WriteValue(DateTime value)
Parameters
WriteValue(DateTimeOffset)
Writes a DateTimeOffset value.
public override void WriteValue(DateTimeOffset value)
Parameters
value
DateTimeOffsetThe DateTimeOffset value to write.
WriteValue(decimal)
Writes a decimal value.
public override void WriteValue(decimal value)
Parameters
WriteValue(double)
Writes a double value.
public override void WriteValue(double value)
Parameters
WriteValue(Guid)
Writes a Guid value.
public override void WriteValue(Guid value)
Parameters
WriteValue(short)
Writes a short value.
public override void WriteValue(short value)
Parameters
WriteValue(int)
Writes a int value.
public override void WriteValue(int value)
Parameters
WriteValue(long)
Writes a long value.
public override void WriteValue(long value)
Parameters
WriteValue(sbyte)
Writes a sbyte value.
[CLSCompliant(false)]
public override void WriteValue(sbyte value)
Parameters
WriteValue(float)
Writes a float value.
public override void WriteValue(float value)
Parameters
WriteValue(string)
Writes a string value.
public override void WriteValue(string value)
Parameters
WriteValue(TimeSpan)
Writes a TimeSpan value.
public override void WriteValue(TimeSpan value)
Parameters
WriteValue(ushort)
Writes a ushort value.
[CLSCompliant(false)]
public override void WriteValue(ushort value)
Parameters
WriteValue(uint)
Writes a uint value.
[CLSCompliant(false)]
public override void WriteValue(uint value)
Parameters
WriteValue(ulong)
Writes a ulong value.
[CLSCompliant(false)]
public override void WriteValue(ulong value)
Parameters
WriteValue(Uri)
Writes a System.Uri value.
public override void WriteValue(Uri value)
Parameters
value
UriThe 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
stringThe string of white space characters.