Ejemplo n.º 1
0
 void _writeArray(Array arr, int[] startIdx, int dim, EasyJsonWriter writer)
 {
     writer.WriteArrayStart();
     for (int i = 0; i < arr.GetLength(dim); ++i)
     {
         startIdx[dim] = i;
         if (dim == arr.Rank - 1)
         {
             //writer.WriteJsonValue(base.ObjectToJson(arr.GetValue(startIdx)));
             writer.WriteValue(arr.GetValue(startIdx));
         }
         else
         {
             _writeArray(arr, startIdx, dim + 1, writer);
             writer.WriteJsonValue("");
         }
     }
     writer.WriteArrayEnd();
 }
Ejemplo n.º 2
0
        public override string ObjectToJson(object obj)
        {
            if (obj == null)
            {
                return(null);
            }

            IList          list   = obj as IList;
            EasyJsonWriter writer = new EasyJsonWriter();

            writer.WriteArrayStart();
            foreach (object element in list)
            {
                //writer.WriteJsonValue(base.ObjectToJson(element));
                writer.WriteValue(element);
            }
            writer.WriteArrayEnd();

            return(writer.ToString());
        }
Ejemplo n.º 3
0
        public override string ToString()
        {
            if (Type == EasyJsonDataType.JsonObject)
            {
                EasyJsonWriter writer = new EasyJsonWriter();
                writer.WriteObjectStart();
                foreach (string name in Names)
                {
                    writer.WriteName(name);
                    writer.WriteJsonValue(this[name].ToString());
                }
                writer.WriteObjectEnd();

                return(writer.ToString());
            }
            else if (Type == EasyJsonDataType.JsonArray)
            {
                EasyJsonWriter writer = new EasyJsonWriter();
                writer.WriteArrayStart();
                for (int i = 0; i < Count; ++i)
                {
                    writer.WriteJsonValue(this[i].ToString());
                }
                writer.WriteArrayEnd();

                return(writer.ToString());
            }
            else if (Type == EasyJsonDataType.JsonString)
            {
                return(JsonUtil.STRING_QUOTE + Data + JsonUtil.STRING_QUOTE);
            }
            else
            {
                return(Data);
            }
        }