public void WriteAsJSON(System.IO.TextWriter writer)
        {
            if (TargetDictionary.Count == 0)
            {
                WriteEmptyArray(writer);
                return;
            }

            writer.WriteLine("{");

            foreach (KeyValuePair <string, object> keyset in TargetDictionary)
            {
                writer.Write(JsonData.JSSafeQuote(keyset.Key));
                writer.Write(":");
                if (keyset.Value is IJsonSerializable)
                {
                    ((IJsonSerializable)keyset.Value).WriteAsJSON(writer);
                }
                else
                {
                    if (AllowReflectiveSerialization)
                    {
                        writer.Write(BaseJsonSerializer.ExpensiveGetJsonDataAsString(keyset.Value));
                    }
                    else
                    {
                        writer.Write(JsonData.JSSafeQuote(keyset.ToString()));
                    }
                }
            }
        }
        public void WriteAsJSON(System.IO.TextWriter writer)
        {
            /*
             *                              IEnumerable simpleList = repeatObjectList as IEnumerable;
             * if (simpleList != null)
             * {
             *      //System.Collections.Hashtable
             *
             *      foreach (object item in simpleList)
             *      {
             *              object realItem = item;
             *              if (item is DictionaryEntry)
             *              {
             *                      realItem = ((DictionaryEntry)item).Value;
             *              }
             */
            bool wroteOpener = false;
            bool isArray     = true;

            foreach (object item in TargetCollection)
            {
                object realItem = item;

                //first loop determine if array or object
                //others prepend a comma
                if (wroteOpener)
                {
                    writer.WriteLine(", ");
                }
                else
                {
                    if (item is DictionaryEntry)
                    {
                        writer.WriteLine("{");
                        isArray = false;
                    }
                    else
                    {
                        writer.WriteLine("[");
                        isArray = true;
                    }
                    wroteOpener = true;
                }

                if (item is DictionaryEntry)
                {
                    realItem = ((DictionaryEntry)item).Value;
                    writer.Write(JsonData.JSSafeQuote(((DictionaryEntry)item).Key.ToString()));
                    writer.Write(":");
                }

                if (realItem is IJsonSerializable)
                {
                    ((IJsonSerializable)realItem).WriteAsJSON(writer);
                }
                else
                {
                    if (AllowReflectiveSerialization)
                    {
                        writer.Write(BaseJsonSerializer.ExpensiveGetJsonDataAsString(realItem));
                    }
                    else
                    {
                        writer.Write(JsonData.JSSafeQuote(realItem.ToString()));
                    }
                }
            }
            if (!wroteOpener)
            {
                WriteEmptyArray(writer);
            }
            else
            {
                if (isArray)
                {
                    writer.WriteLine("]");
                }
                else
                {
                    writer.WriteLine("}");
                }
            }
        }