/// <summary> /// /// </summary> /// <param name="value"></param> private void serialize(ref Node value) { switch (value.Type) { case NodeType.Dictionary: CharStream.Write('{'); if ((int)value.Int64 != 0) { KeyValue <Node, Node>[] array = value.DictionaryArray; for (int index = 0; index != (int)value.Int64; ++index) { if (index != 0) { CharStream.Write(','); } serialize(ref array[index].Key); CharStream.Write(':'); serialize(ref array[index].Value); } } CharStream.Write('}'); return; case NodeType.Array: CharStream.Write('['); if ((int)value.Int64 != 0) { Node[] array = value.ListArray; for (int index = 0; index != (int)value.Int64; ++index) { if (index != 0) { CharStream.Write(','); } serialize(ref array[index]); CharStream.Write(':'); serialize(ref array[index]); } } CharStream.Write(']'); return; case NodeType.String: { SubString subString = value.SubString; CharStream.WriteJson(ref subString, Config.NullChar); } return; case NodeType.QuoteString: case NodeType.ErrorQuoteString: CharStream.PrepCharSize(value.SubString.Length + 2); CharStream.Data.Write((char)value.Int64); CharStream.Write(ref value.SubString); CharStream.Data.Write((char)value.Int64); return; case NodeType.NumberString: if ((int)value.Int64 == 0) { CharStream.Write(ref value.SubString); } else { CharStream.PrepCharSize(value.SubString.Length + 2); CharStream.Data.Write((char)value.Int64); CharStream.Write(ref value.SubString); CharStream.Data.Write((char)value.Int64); } return; case NodeType.Bool: CallSerialize((int)value.Int64 != 0); return; case NodeType.DateTimeTick: CallSerialize(new DateTime(value.Int64, DateTimeKind.Local)); return; case NodeType.NaN: CharStream.WriteJsonNaN(); return; case NodeType.PositiveInfinity: if (Config.IsInfinityToNaN) { CharStream.WriteJsonNaN(); } else { CharStream.WritePositiveInfinity(); } return; case NodeType.NegativeInfinity: if (Config.IsInfinityToNaN) { CharStream.WriteJsonNaN(); } else { CharStream.WriteNegativeInfinity(); } return; default: CharStream.WriteJsonNull(); return; } }