Exemplo n.º 1
0
        protected static bool serializeObjectOrArray(object objectOrArray, StringBuilder builder)
        {
            bool result;

            if (objectOrArray is Hashtable)
            {
                result = MUJson.serializeObject((Hashtable)objectOrArray, builder);
            }
            else
            {
                result = (objectOrArray is ArrayList && MUJson.serializeArray((ArrayList)objectOrArray, builder));
            }
            return(result);
        }
Exemplo n.º 2
0
 protected static bool serializeValue(object value, StringBuilder builder)
 {
     if (value == null)
     {
         builder.Append("null");
     }
     else if (value.GetType().IsArray)
     {
         MUJson.serializeArray(new ArrayList((ICollection)value), builder);
     }
     else if (value is string)
     {
         MUJson.serializeString((string)value, builder);
     }
     else if (value is char)
     {
         MUJson.serializeString(Convert.ToString((char)value), builder);
     }
     else if (value is Hashtable)
     {
         MUJson.serializeObject((Hashtable)value, builder);
     }
     else if (value is Dictionary <string, string> )
     {
         MUJson.serializeDictionary((Dictionary <string, string>)value, builder);
     }
     else if (value is ArrayList)
     {
         MUJson.serializeArray((ArrayList)value, builder);
     }
     else if (value is bool && (bool)value)
     {
         builder.Append("true");
     }
     else if (value is bool && !(bool)value)
     {
         builder.Append("false");
     }
     else
     {
         if (!value.GetType().IsPrimitive)
         {
             return(false);
         }
         MUJson.serializeNumber(Convert.ToDouble(value), builder);
     }
     return(true);
 }