Namespace: | Sirenix.Serialization |
Assembly: | Sirenix.Serialization |
public class JsonDataWriter : BaseDataWriter, IDataWriter, IDisposable
public JsonDataWriter()
public JsonDataWriter(Stream stream, SerializationContext context, bool formatAsReadable = true)
System.IO.Stream | stream | The base stream of the writer. |
SerializationContext | context | The serialization context to use. |
System.Boolean | formatAsReadable | Whether the json should be packed, or formatted as human-readable. |
public bool EnableTypeOptimization
public bool FormatAsReadable
public override void BeginArrayNode(long length)
System.Int64 | length | The length of the array to come. |
This call MUST eventually be followed by a corresponding call to Sirenix.Serialization.IDataWriter.EndNode(System.String), with the same name.
public override void BeginReferenceNode(string name, Type type, int id)
System.String | name | The name of the reference node. |
System.Type | type | The type of the reference node. If null, no type metadata will be written. |
System.Int32 | id | The id of the reference node. This id is acquired by calling TryRegisterInternalReference(Object, out Int32). |
This call MUST eventually be followed by a corresponding call to Sirenix.Serialization.IDataWriter.EndNode(System.String), with the same name.
public override void BeginStructNode(string name, Type type)
System.String | name | The name of the struct node. |
System.Type | type | The type of the struct node. If null, no type metadata will be written. |
public override void Dispose()
public override void EndArrayNode()
public override void EndNode(string name)
System.String | name | The name of the node to end. This has to be the name of the current node. |
public override void FlushToStream()
public override string GetDataDump()
System.String |
public void MarkJustStarted()
public override void PrepareNewSerializationSession()
public override void WriteBoolean(string name, bool value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Boolean | value | The value to write. |
public override void WriteByte(string name, byte value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Byte | value | The value to write. |
public override void WriteChar(string name, char value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Char | value | The value to write. |
public override void WriteDecimal(string name, decimal value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Decimal | value | The value to write. |
public override void WriteDouble(string name, double value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Double | value | The value to write. |
public override void WriteExternalReference(string name, Guid guid)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Guid | guid | The value to write. |
public override void WriteExternalReference(string name, int index)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Int32 | index | The value to write. |
public override void WriteExternalReference(string name, string id)
System.String | name | The name of the value. If this is null, no name will be written. |
System.String | id | The value to write. |
public override void WriteGuid(string name, Guid value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Guid | value | The value to write. |
public override void WriteInt16(string name, short value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Int16 | value | The value to write. |
public override void WriteInt32(string name, int value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Int32 | value | The value to write. |
public override void WriteInt64(string name, long value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Int64 | value | The value to write. |
public override void WriteInternalReference(string name, int id)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Int32 | id | The value to write. |
public override void WriteNull(string name)
System.String | name | The name of the value. If this is null, no name will be written. |
public override void WritePrimitiveArray<T>(T[] array)
where T : struct
T[] | array | The primitive array to write. |
T | The element type of the primitive array. Valid element types can be determined using IsPrimitiveArrayType(Type). |
System.ArgumentException | Type + typeof(T).Name + is not a valid primitive array type. |
System.ArgumentNullException | array |
public override void WriteSByte(string name, sbyte value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.SByte | value | The value to write. |
public override void WriteSingle(string name, float value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.Single | value | The value to write. |
public override void WriteString(string name, string value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.String | value | The value to write. |
public override void WriteUInt16(string name, ushort value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.UInt16 | value | The value to write. |
public override void WriteUInt32(string name, uint value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.UInt32 | value | The value to write. |
public override void WriteUInt64(string name, ulong value)
System.String | name | The name of the value. If this is null, no name will be written. |
System.UInt64 | value | The value to write. |