Class JsonWriter
Represents a writer that provides a fast, non-cached, forward-only way of generating JSON data.
Implements
Inherited Members
Namespace: Bayat.Json
Assembly: Bayat.Json.Runtime.dll
Syntax
public abstract class JsonWriter : IDisposable
Constructors
| Improve this Doc View SourceJsonWriter()
Creates an instance of the JsonWriter
class.
Declaration
protected JsonWriter()
Fields
| Improve this Doc View SourceStateArrayTempate
Declaration
public static readonly JsonWriter.State[][] StateArrayTempate
Field Value
Type | Description |
---|---|
Json |
Properties
| Improve this Doc View SourceCloseOutput
Gets or sets a value indicating whether the underlying stream or
System.
Declaration
public bool CloseOutput { get; set; }
Property Value
Type | Description |
---|---|
System. |
true to close the underlying stream or System. |
ContainerPath
Declaration
public string ContainerPath { get; }
Property Value
Type | Description |
---|---|
System. |
Culture
Gets or sets the culture used when writing JSON. Defaults to System.
Declaration
public CultureInfo Culture { get; set; }
Property Value
Type | Description |
---|---|
System. |
DateFormatHandling
Get or set how dates are written to JSON text.
Declaration
public DateFormatHandling DateFormatHandling { get; set; }
Property Value
Type | Description |
---|---|
Date |
DateFormatString
Get or set how System.
Declaration
public string DateFormatString { get; set; }
Property Value
Type | Description |
---|---|
System. |
DateTimeZoneHandling
Get or set how System.
Declaration
public DateTimeZoneHandling DateTimeZoneHandling { get; set; }
Property Value
Type | Description |
---|---|
Date |
FloatFormatHandling
Get or set how special floating point numbers, e.g. System.
Declaration
public FloatFormatHandling FloatFormatHandling { get; set; }
Property Value
Type | Description |
---|---|
Float |
Formatting
Indicates how JSON text output is formatted.
Declaration
public Formatting Formatting { get; set; }
Property Value
Type | Description |
---|---|
Formatting |
Path
Gets the path of the writer.
Declaration
public string Path { get; }
Property Value
Type | Description |
---|---|
System. |
StringEscapeHandling
Get or set how strings are escaped when writing JSON text.
Declaration
public StringEscapeHandling StringEscapeHandling { get; set; }
Property Value
Type | Description |
---|---|
String |
Top
Gets the top.
Declaration
public int Top { get; }
Property Value
Type | Description |
---|---|
System. |
The top. |
WriteState
Gets the state of the writer.
Declaration
public WriteState WriteState { get; }
Property Value
Type | Description |
---|---|
Write |
Methods
| Improve this Doc View SourceAutoComplete(JsonToken)
Declaration
public void AutoComplete(JsonToken tokenBeingWritten)
Parameters
Type | Name | Description |
---|---|---|
Json |
tokenBeingWritten |
BuildStateArray()
Declaration
public static JsonWriter.State[][] BuildStateArray()
Returns
Type | Description |
---|---|
Json |
Close()
Closes this stream and the underlying stream.
Declaration
public virtual void Close()
Dispose(Boolean)
Releases unmanaged and - optionally - managed resources
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System. |
disposing |
|
Flush()
Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.
Declaration
public abstract void Flush()
InternalWriteComment()
Declaration
protected void InternalWriteComment()
InternalWriteEnd(JsonContainerType)
Declaration
protected void InternalWriteEnd(JsonContainerType container)
Parameters
Type | Name | Description |
---|---|---|
Json |
container |
InternalWritePropertyName(String)
Declaration
protected void InternalWritePropertyName(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name |
InternalWriteRaw()
Declaration
protected void InternalWriteRaw()
InternalWriteStart(JsonToken, JsonContainerType)
Declaration
protected void InternalWriteStart(JsonToken token, JsonContainerType container)
Parameters
Type | Name | Description |
---|---|---|
Json |
token | |
Json |
container |
InternalWriteValue(JsonToken)
Declaration
protected void InternalWriteValue(JsonToken token)
Parameters
Type | Name | Description |
---|---|---|
Json |
token |
InternalWriteWhitespace(String)
Declaration
protected void InternalWriteWhitespace(string ws)
Parameters
Type | Name | Description |
---|---|---|
System. |
ws |
OnStringEscapeHandlingChanged()
Declaration
protected virtual void OnStringEscapeHandlingChanged()
SetWriteState(JsonToken, Object)
Sets the state of the JsonWriter,
Declaration
protected void SetWriteState(JsonToken token, object value)
Parameters
Type | Name | Description |
---|---|---|
Json |
token | The JsonToken being written. |
System. |
value | The value being written. |
UpdateScopeWithFinishedValue()
Declaration
public void UpdateScopeWithFinishedValue()
WriteComment(String)
Writes out a comment
/.../
containing the specified text.
Declaration
public virtual void WriteComment(string text)
Parameters
Type | Name | Description |
---|---|---|
System. |
text | Text to place inside the comment. |
WriteEnd()
Writes the end of the current JSON object or array.
Declaration
public virtual void WriteEnd()
WriteEnd(JsonToken)
Writes the specified end token.
Declaration
protected virtual void WriteEnd(JsonToken token)
Parameters
Type | Name | Description |
---|---|---|
Json |
token | The end token to write. |
WriteEndArray()
Writes the end of an array.
Declaration
public virtual void WriteEndArray()
WriteEndConstructor()
Writes the end constructor.
Declaration
public virtual void WriteEndConstructor()
WriteEndObject()
Writes the end of a JSON object.
Declaration
public virtual void WriteEndObject()
WriteIndent()
Writes indent characters.
Declaration
protected virtual void WriteIndent()
WriteIndentSpace()
Writes an indent space.
Declaration
protected virtual void WriteIndentSpace()
WriteNull()
Writes a null value.
Declaration
public virtual void WriteNull()
WriteProperty(String, Object)
Writes the property name and value of a name/value pair on a JSON object.
Declaration
public virtual void WriteProperty(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the property. |
System. |
value | The value of the property. |
WritePropertyName(String)
Writes the property name of a name/value pair on a JSON object.
Declaration
public virtual void WritePropertyName(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the property. |
WritePropertyName(String, Boolean)
Writes the property name of a name/value pair on a JSON object.
Declaration
public virtual void WritePropertyName(string name, bool escape)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the property. |
System. |
escape | A flag to indicate whether the text should be escaped when it is written as a JSON property name. |
WriteRaw(String)
Writes raw JSON without changing the writer's state.
Declaration
public virtual void WriteRaw(string json)
Parameters
Type | Name | Description |
---|---|---|
System. |
json | The raw JSON to write. |
WriteRawValue(String)
Writes raw JSON where a value is expected and updates the writer's state.
Declaration
public virtual void WriteRawValue(string json)
Parameters
Type | Name | Description |
---|---|---|
System. |
json | The raw JSON to write. |
WriteStartArray()
Writes the beginning of a JSON array.
Declaration
public virtual void WriteStartArray()
WriteStartConstructor(String)
Writes the start of a constructor with the given name.
Declaration
public virtual void WriteStartConstructor(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the constructor. |
WriteStartObject()
Writes the beginning of a JSON object.
Declaration
public virtual void WriteStartObject()
WriteToken(JsonReader)
Writes the current Json
Declaration
public void WriteToken(JsonReader reader)
Parameters
Type | Name | Description |
---|---|---|
Json |
reader | The Json |
WriteToken(JsonReader, Boolean)
Writes the current Json
Declaration
public void WriteToken(JsonReader reader, bool writeChildren)
Parameters
Type | Name | Description |
---|---|---|
Json |
reader | The Json |
System. |
writeChildren | A flag indicating whether the current token's children should be written. |
WriteToken(JsonReader, Boolean, Boolean, Boolean)
Declaration
public virtual void WriteToken(JsonReader reader, bool writeChildren, bool writeDateConstructorAsDate, bool writeComments)
Parameters
Type | Name | Description |
---|---|---|
Json |
reader | |
System. |
writeChildren | |
System. |
writeDateConstructorAsDate | |
System. |
writeComments |
WriteToken(JsonToken)
Writes the Json
Declaration
public void WriteToken(JsonToken token)
Parameters
| Improve this Doc View SourceWriteToken(JsonToken, Object)
Writes the Json
Declaration
public void WriteToken(JsonToken token, object value)
Parameters
Type | Name | Description |
---|---|---|
Json |
token | The Json |
System. |
value | The value to write.
A value is only required for tokens that have an associated value, e.g. the System. |
WriteUndefined()
Writes an undefined value.
Declaration
public virtual void WriteUndefined()
WriteValue(JsonWriter, PrimitiveTypeCode, Object)
Declaration
public static void WriteValue(JsonWriter writer, PrimitiveTypeCode typeCode, object value)
Parameters
Type | Name | Description |
---|---|---|
Json |
writer | |
Primitive |
typeCode | |
System. |
value |
WriteValue(Boolean)
Writes a System.
Declaration
public virtual void WriteValue(bool value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Byte)
Writes a System.
Declaration
public virtual void WriteValue(byte value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Byte[])
Writes a System.
Declaration
public virtual void WriteValue(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Char)
Writes a System.
Declaration
public virtual void WriteValue(char value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(DateTime)
Writes a System.
Declaration
public virtual void WriteValue(DateTime value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(DateTimeOffset)
Writes a System.
Declaration
public virtual void WriteValue(DateTimeOffset value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Decimal)
Writes a System.
Declaration
public virtual void WriteValue(decimal value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Double)
Writes a System.
Declaration
public virtual void WriteValue(double value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Guid)
Writes a System.
Declaration
public virtual void WriteValue(Guid value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Int16)
Writes a System.
Declaration
public virtual void WriteValue(short value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Int32)
Writes a System.
Declaration
public virtual void WriteValue(int value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Int64)
Writes a System.
Declaration
public virtual void WriteValue(long value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Nullable<Boolean>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(bool? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<Byte>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(byte? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<Char>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(char? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<DateTime>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(DateTime? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<DateTimeOffset>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(DateTimeOffset? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<Decimal>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(decimal? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<Double>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(double? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<Guid>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(Guid? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<Int16>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(short? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<Int32>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(int? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<Int64>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(long? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<SByte>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(sbyte? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<Single>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(float? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<TimeSpan>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(TimeSpan? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<UInt16>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(ushort? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<UInt32>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(uint? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Nullable<UInt64>)
Writes a System.Nullable<T> value.
Declaration
public virtual void WriteValue(ulong? value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System.Nullable<T> value to write. |
WriteValue(Object)
Writes a System.
Declaration
public virtual void WriteValue(object value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(SByte)
Writes a System.
Declaration
public virtual void WriteValue(sbyte value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Single)
Writes a System.
Declaration
public virtual void WriteValue(float value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(String)
Writes a System.
Declaration
public virtual void WriteValue(string value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(TimeSpan)
Writes a System.
Declaration
public virtual void WriteValue(TimeSpan value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(UInt16)
Writes a System.
Declaration
public virtual void WriteValue(ushort value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(UInt32)
Writes a System.
Declaration
public virtual void WriteValue(uint value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(UInt64)
Writes a System.
Declaration
public virtual void WriteValue(ulong value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValue(Uri)
Writes a System.
Declaration
public virtual void WriteValue(Uri value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The System. |
WriteValueDelimiter()
Writes the JSON value delimiter.
Declaration
protected virtual void WriteValueDelimiter()
WriteWhitespace(String)
Writes out the given white space.
Declaration
public virtual void WriteWhitespace(string ws)
Parameters
Type | Name | Description |
---|---|---|
System. |
ws | The string of white space characters. |
Explicit Interface Implementations
| Improve this Doc View SourceIDisposable.Dispose()
Declaration
void IDisposable.Dispose()