Class JsonWriter
Represents a writer that provides a fast, non-cached, forward-only means of generating streams or files containing JSON data.
Inheritance
Implements
Namespace: Cuemon.Runtime.Serialization
Assembly: Cuemon.Runtime.dll
Syntax
public abstract class JsonWriter : IDisposable
Constructors
| Improve this DocJsonWriter(Stream)
Initializes a new instance of the JsonWriter class.
Declaration
protected JsonWriter(Stream output)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | output | The System.IO.Stream to which you want to write. |
JsonWriter(Stream, Encoding)
Initializes a new instance of the JsonWriter class.
Declaration
protected JsonWriter(Stream output, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | output | The System.IO.Stream to which you want to write. |
System.Text.Encoding | encoding | The character encoding to use in the generated |
Fields
| Improve this DocBeginArray
Represents the begin-array character as defined in RFC 4627.
Declaration
public static readonly string BeginArray
Field Value
Type | Description |
---|---|
System.String |
BeginObject
Represents the begin-object character as defined in RFC 4627.
Declaration
public static readonly string BeginObject
Field Value
Type | Description |
---|---|
System.String |
EndArray
Represents the end-array character as defined in RFC 4627.
Declaration
public static readonly string EndArray
Field Value
Type | Description |
---|---|
System.String |
EndObject
Represents the end-object character as defined in RFC 4627.
Declaration
public static readonly string EndObject
Field Value
Type | Description |
---|---|
System.String |
NameSeperator
Represents the name-seperator character as defined in RFC 4627.
Declaration
public static readonly string NameSeperator
Field Value
Type | Description |
---|---|
System.String |
ValueSeperator
Represents the value-seperator character as defined in RFC 4627.
Declaration
public static readonly string ValueSeperator
Field Value
Type | Description |
---|---|
System.String |
Properties
| Improve this DocEncoding
Gets the character encoding used by this instance of the JsonWriter.
Declaration
public Encoding Encoding { get; }
Property Value
Type | Description |
---|---|
System.Text.Encoding |
IsDisposed
Gets a value indicating whether this instance is disposed.
Declaration
protected bool IsDisposed { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Methods
| Improve this DocCreate(Stream)
Creates a new JsonWriter instance using the specified stream.
Declaration
public static JsonWriter Create(Stream output)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | output | The System.IO.Stream to which you want to write. |
Returns
Type | Description |
---|---|
JsonWriter | An JsonWriter object. |
Create(Stream, Encoding)
Creates a new JsonWriter instance using the specified stream.
Declaration
public static JsonWriter Create(Stream output, Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | output | The System.IO.Stream to which you want to write. |
System.Text.Encoding | encoding | The character encoding to use in the generated |
Returns
Type | Description |
---|---|
JsonWriter | An JsonWriter object. |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(Boolean)
Releases unmanaged and - optionally - managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
|
Flush()
Clears all buffers for the current writer and causes any buffered data to be written to the underlying stream.
Declaration
public void Flush()
ValidateEncoding(Encoding)
Validates the specified encoding
according to RFC 4627.
Declaration
public static void ValidateEncoding(Encoding encoding)
Parameters
Type | Name | Description |
---|---|---|
System.Text.Encoding | encoding | The character encoding to validate. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException |
|
WriteComment(String)
Writes out a comment
/.../
containing the specified text.
Declaration
public void WriteComment(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text to place inside the comment. |
WriteEndArray()
Writes the EndArray tag of a JSON array.
Declaration
public void WriteEndArray()
WriteEndObject()
Writes the EndObject tag of a JSON object.
Declaration
public void WriteEndObject()
WriteObject(String)
Writes a JSON object with no value associated.
Declaration
public void WriteObject(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
WriteObject(String, Boolean)
Writes a boolean JSON object.
Declaration
public void WriteObject(string name, bool value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Boolean | value | The System.Boolean value of the JSON object. |
WriteObject(String, Byte)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, byte value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Byte | value | The System.Byte value of the JSON object. |
WriteObject(String, Byte[])
Writes a base64 encoded string JSON object.
Declaration
public void WriteObject(string name, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Byte[] | value | The binary value of the JSON object. |
WriteObject(String, Char)
Writes a string JSON object.
Declaration
public void WriteObject(string name, char value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Char | value | The System.Char value of the JSON object. |
WriteObject(String, DateTime)
Writes a string JSON object.
Declaration
public void WriteObject(string name, DateTime value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.DateTime | value | The System.DateTime value of the JSON object. |
WriteObject(String, Decimal)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, decimal value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Decimal | value | The System.Decimal value of the JSON object. |
WriteObject(String, Double)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, double value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Double | value | The System.Double value of the JSON object. |
WriteObject(String, Guid)
Writes a string JSON object.
Declaration
public void WriteObject(string name, Guid value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Guid | value | The System.Guid value of the JSON object. |
WriteObject(String, Int16)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, short value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Int16 | value | The System.Int16 value of the JSON object. |
WriteObject(String, Int32)
Writes a string JSON object.
Declaration
public void WriteObject(string name, int value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Int32 | value | The System.Int32 value of the JSON object. |
WriteObject(String, Int64)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, long value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Int64 | value | The System.Int64 value of the JSON object. |
WriteObject(String, Object)
Writes a JSON object.
Declaration
public void WriteObject(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Object | value | The value of the JSON object. |
WriteObject(String, SByte)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, sbyte value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.SByte | value | The System.SByte value of the JSON object. |
WriteObject(String, Single)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, float value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.Single | value | The System.Single value of the JSON object. |
WriteObject(String, String)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.String | value | The System.String value of the JSON object. |
WriteObject(String, UInt16)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.UInt16 | value | The System.UInt16 value of the JSON object. |
WriteObject(String, UInt32)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, uint value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.UInt32 | value | The System.UInt32 value of the JSON object. |
WriteObject(String, UInt64)
Writes a numeric JSON object.
Declaration
public void WriteObject(string name, ulong value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
System.UInt64 | value | The System.UInt64 value of the JSON object. |
WriteObjectName(String)
Writes the name of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectName(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the JSON object. |
WriteObjectValue(Boolean)
Writes the boolean value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(bool value)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | value | The value of the JSON object. |
WriteObjectValue(Byte)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | The value of the JSON object. |
WriteObjectValue(Byte[])
Writes the string value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value of the JSON object. |
Remarks
value
is converted to a Base64 encoded string.
WriteObjectValue(Char)
Writes the string value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(char value)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | The value of the JSON object. |
WriteObjectValue(DateTime)
Writes the string value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(DateTime value)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | value | The value of the JSON object. |
WriteObjectValue(Decimal)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(decimal value)
Parameters
Type | Name | Description |
---|---|---|
System.Decimal | value | The value of the JSON object. |
WriteObjectValue(Double)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The value of the JSON object. |
WriteObjectValue(Guid)
Writes the string value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(Guid value)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | value | The value of the JSON object. |
WriteObjectValue(Int16)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(short value)
Parameters
Type | Name | Description |
---|---|---|
System.Int16 | value | The value of the JSON object. |
WriteObjectValue(Int32)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value of the JSON object. |
WriteObjectValue(Int64)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value of the JSON object. |
WriteObjectValue(Object)
Writes the value of a JSON object.
Declaration
public void WriteObjectValue(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The value of the JSON object. |
Remarks
value
is checked and written accordingly by the System.IConvertible interface.
WriteObjectValue(SByte)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(sbyte value)
Parameters
Type | Name | Description |
---|---|---|
System.SByte | value | The value of the JSON object. |
WriteObjectValue(Single)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(float value)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | The value of the JSON object. |
WriteObjectValue(String)
Writes the string value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value of the JSON object. |
WriteObjectValue(UInt16)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(ushort value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | value | The value of the JSON object. |
WriteObjectValue(UInt32)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(uint value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | value | The value of the JSON object. |
WriteObjectValue(UInt64)
Writes the numeric value of a JSON object as defined in RFC 4627.
Declaration
public void WriteObjectValue(ulong value)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | value | The value of the JSON object. |
WriteRaw(String)
Writes the raw JSON manually from a string.
Declaration
public void WriteRaw(string data)
Parameters
Type | Name | Description |
---|---|---|
System.String | data | String containing the text to write. |
WriteStartArray()
Writes the BeginArray tag of a JSON array.
Declaration
public void WriteStartArray()
WriteStartObject()
Writes the BeginObject tag of a JSON object.
Declaration
public void WriteStartObject()
WriteValueSeperator()
Writes the ValueSeperator.
Declaration
public void WriteValueSeperator()