Beispiel #1
0
 protected static bool serializeObjectOrArray(object objectOrArray, StringBuilder builder)
 {
     if (objectOrArray is Hashtable)
     {
         return(MiniJSON.serializeObject((Hashtable)objectOrArray, builder));
     }
     return(objectOrArray is ArrayList && MiniJSON.serializeArray((ArrayList)objectOrArray, builder));
 }
Beispiel #2
0
 protected static bool serializeValue(object value, StringBuilder builder)
 {
     if (value == null)
     {
         builder.Append("null");
     }
     else if (value.GetType().get_IsArray())
     {
         MiniJSON.serializeArray(new ArrayList((ICollection)value), builder);
     }
     else if (value is string)
     {
         MiniJSON.serializeString((string)value, builder);
     }
     else if (value is char)
     {
         MiniJSON.serializeString(Convert.ToString((char)value), builder);
     }
     else if (value is Hashtable)
     {
         MiniJSON.serializeObject((Hashtable)value, builder);
     }
     else if (value is Dictionary <string, string> )
     {
         MiniJSON.serializeDictionary((Dictionary <string, string>)value, builder);
     }
     else if (value is ArrayList)
     {
         MiniJSON.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().get_IsPrimitive())
         {
             return(false);
         }
         MiniJSON.serializeNumber(Convert.ToDouble(value), builder);
     }
     return(true);
 }